octodns.record.srv

Classes

SrvNameRfcValidator(id[, sets])

Strict SRV name validator per RFC 2782 and RFC 6335 §5.1.

SrvNameValidator(id[, sets])

Validates that an SRV record's name matches the _service._protocol pattern required by RFC 2782 (e.g. _http._tcp), or is a wildcard.

SrvRecord(zone, name, data[, source, context])

SrvValue(value)

SrvValueBestPracticeValidator(id[, sets])

Checks that the SRV target field ends with a trailing . (fully-qualified name).

SrvValueNotIpValidator(id[, sets])

Checks that the SRV target field is not an IP address.

SrvValueRfcValidator(id[, sets])

Strict SRV rdata validator per RFC 2782.

SrvValueValidator(id[, sets])

Validates SRV rdata: priority, weight, and port are present and integer-parsable, and target is a valid FQDN.

class octodns.record.srv.SrvNameValidator(id, sets=None)[source]

Bases: RecordValidator

Validates that an SRV record’s name matches the _service._protocol pattern required by RFC 2782 (e.g. _http._tcp), or is a wildcard.

_name_re = re.compile('^(\\*|_[^\\.]+)\\.[^\\.]+')
validate(record_cls, name, fqdn, data, disabled=None)[source]

Validate a record’s non-value attributes.

Parameters:
  • record_cls (type) – The concrete Record subclass being validated. Validators that need access to record class-level attributes (e.g. _type, _value_type) should read them from record_cls. Per-instance configuration should live on self, not on record_cls.

  • name (str) – The record’s name relative to its zone ('' for the zone root). Already idna_encode’d.

  • fqdn (str) – The record’s fully-qualified domain name (name + zone name).

  • data (dict) – The raw record config dict (as loaded from YAML/JSON) including ttl, type, value/values, and any type-specific fields like dynamic, geo, or octodns.

  • disabled (dict or None) – The zone’s per-type map of disabled validator ids (record_cls ._type or '*' -> set of ids), as configured via the zone’s validators.record.disable_validators. Most validators can ignore this; it only matters to validators that themselves dispatch to other validators (e.g. value-type bridges, geo and dynamic validators), which must forward it along so the disabled ids are honored down the chain.

Returns:

A list of ValidationReason objects describing validation failures — construct each with ValidationReason(reason, validator_id=self.id). Must return an empty list when the record is valid. Reasons from multiple validators are concatenated by the caller, so each reason must stand alone without context from the others. Returning bare str reasons is DEPRECATED — the registry wraps them in ValidationReason and emits a deprecation warning; support will be removed in 2.0.

Return type:

list[ValidationReason]

Notes

Implementations must not raise on invalid input — all failures are reported via the returned list. Reason text is surfaced verbatim in ValidationError messages, so phrasing and punctuation should be stable across releases.

Third-party validators that predate the disabled parameter and implement validate(self, record_cls, name, fqdn, data) continue to work: the caller detects the TypeError and falls back to calling without it, emitting a deprecation warning. Support for the parameter-less form will be removed in 2.0.

class octodns.record.srv.SrvValueValidator(id, sets=None)[source]

Bases: ValueValidator

Validates SRV rdata: priority, weight, and port are present and integer-parsable, and target is a valid FQDN.

validate(value_cls, data, _type)[source]

Validate a record’s rdata values.

Parameters:
  • value_cls (type) – The concrete value class being validated (e.g. MxValue, _Ipv4Value). Validators that need access to value class-level attributes (e.g. VALID_ALGORITHMS, _address_type) should read them from value_cls. Per-instance configuration should live on self, not on value_cls.

  • data (list | tuple | str | dict) – The rdata to validate. For multi-value record types this is a list/tuple of value dicts or strings; for single-value types it may be a bare value. Most validators iterate data directly — when a validator needs to accept either form it should normalize with if not isinstance(data, (list, tuple)): data = (data,).

  • _type (str) – The record type string (e.g. 'MX', 'A'). Passed through to helpers like _check_target_format which format it into their reason strings.

Returns:

A list of ValidationReason objects describing validation failures — construct each with ValidationReason(reason, validator_id=self.id). Must return an empty list when the values are valid. Reasons from multiple validators are concatenated by the caller, so each reason must stand alone without context from the others. Returning bare str reasons is DEPRECATED — the registry wraps them in ValidationReason and emits a deprecation warning; support will be removed in 2.0.

Return type:

list[ValidationReason]

Notes

Implementations must not raise on invalid input — all failures are reported via the returned list. Reason strings are surfaced verbatim in ValidationError messages, so phrasing and punctuation should be stable across releases.

class octodns.record.srv.SrvNameRfcValidator(id, sets=None)[source]

Bases: RecordValidator

Strict SRV name validator per RFC 2782 and RFC 6335 §5.1.

Requires the first two labels of the record name to be _service._proto (*._proto is still accepted for wildcards). Both the service and proto label bodies (after the leading _) must conform to the RFC 6335 §5.1 service name syntax: 1-15 characters, starting with a letter, ending with a letter or digit, containing only letters, digits, and hyphens, and with no consecutive hyphens.

Enabled as part of the rfc validator set:

manager:
  enabled:
    - rfc
_max_len = 15
classmethod _is_valid_service_name(body)[source]
validate(record_cls, name, fqdn, data, disabled=None)[source]

Validate a record’s non-value attributes.

Parameters:
  • record_cls (type) – The concrete Record subclass being validated. Validators that need access to record class-level attributes (e.g. _type, _value_type) should read them from record_cls. Per-instance configuration should live on self, not on record_cls.

  • name (str) – The record’s name relative to its zone ('' for the zone root). Already idna_encode’d.

  • fqdn (str) – The record’s fully-qualified domain name (name + zone name).

  • data (dict) – The raw record config dict (as loaded from YAML/JSON) including ttl, type, value/values, and any type-specific fields like dynamic, geo, or octodns.

  • disabled (dict or None) – The zone’s per-type map of disabled validator ids (record_cls ._type or '*' -> set of ids), as configured via the zone’s validators.record.disable_validators. Most validators can ignore this; it only matters to validators that themselves dispatch to other validators (e.g. value-type bridges, geo and dynamic validators), which must forward it along so the disabled ids are honored down the chain.

Returns:

A list of ValidationReason objects describing validation failures — construct each with ValidationReason(reason, validator_id=self.id). Must return an empty list when the record is valid. Reasons from multiple validators are concatenated by the caller, so each reason must stand alone without context from the others. Returning bare str reasons is DEPRECATED — the registry wraps them in ValidationReason and emits a deprecation warning; support will be removed in 2.0.

Return type:

list[ValidationReason]

Notes

Implementations must not raise on invalid input — all failures are reported via the returned list. Reason text is surfaced verbatim in ValidationError messages, so phrasing and punctuation should be stable across releases.

Third-party validators that predate the disabled parameter and implement validate(self, record_cls, name, fqdn, data) continue to work: the caller detects the TypeError and falls back to calling without it, emitting a deprecation warning. Support for the parameter-less form will be removed in 2.0.

class octodns.record.srv.SrvValueRfcValidator(id, sets=None)[source]

Bases: ValueValidator

Strict SRV rdata validator per RFC 2782.

  • priority, weight, and port must each be in the 0-65535 range.

  • When target is ".", priority, weight, and port must all be 0 (RFC 2782 “service not available” convention).

  • When target is not ".", port must be greater than 0 (port 0 is IANA-reserved).

Assumes the base SrvValueValidator has already caught missing or non-integer fields; entries that fail those checks are skipped here to avoid duplicated reasons. Enabled as part of the rfc validator set:

manager:
  enabled:
    - rfc
static _as_int(value, field)[source]
validate(value_cls, data, _type)[source]

Validate a record’s rdata values.

Parameters:
  • value_cls (type) – The concrete value class being validated (e.g. MxValue, _Ipv4Value). Validators that need access to value class-level attributes (e.g. VALID_ALGORITHMS, _address_type) should read them from value_cls. Per-instance configuration should live on self, not on value_cls.

  • data (list | tuple | str | dict) – The rdata to validate. For multi-value record types this is a list/tuple of value dicts or strings; for single-value types it may be a bare value. Most validators iterate data directly — when a validator needs to accept either form it should normalize with if not isinstance(data, (list, tuple)): data = (data,).

  • _type (str) – The record type string (e.g. 'MX', 'A'). Passed through to helpers like _check_target_format which format it into their reason strings.

Returns:

A list of ValidationReason objects describing validation failures — construct each with ValidationReason(reason, validator_id=self.id). Must return an empty list when the values are valid. Reasons from multiple validators are concatenated by the caller, so each reason must stand alone without context from the others. Returning bare str reasons is DEPRECATED — the registry wraps them in ValidationReason and emits a deprecation warning; support will be removed in 2.0.

Return type:

list[ValidationReason]

Notes

Implementations must not raise on invalid input — all failures are reported via the returned list. Reason strings are surfaced verbatim in ValidationError messages, so phrasing and punctuation should be stable across releases.

class octodns.record.srv.SrvValueBestPracticeValidator(id, sets=None)[source]

Bases: ValueValidator

Checks that the SRV target field ends with a trailing . (fully-qualified name).

Enabled as part of the best-practice validator set:

manager:
  enabled:
    - best-practice
validate(value_cls, data, _type)[source]

Validate a record’s rdata values.

Parameters:
  • value_cls (type) – The concrete value class being validated (e.g. MxValue, _Ipv4Value). Validators that need access to value class-level attributes (e.g. VALID_ALGORITHMS, _address_type) should read them from value_cls. Per-instance configuration should live on self, not on value_cls.

  • data (list | tuple | str | dict) – The rdata to validate. For multi-value record types this is a list/tuple of value dicts or strings; for single-value types it may be a bare value. Most validators iterate data directly — when a validator needs to accept either form it should normalize with if not isinstance(data, (list, tuple)): data = (data,).

  • _type (str) – The record type string (e.g. 'MX', 'A'). Passed through to helpers like _check_target_format which format it into their reason strings.

Returns:

A list of ValidationReason objects describing validation failures — construct each with ValidationReason(reason, validator_id=self.id). Must return an empty list when the values are valid. Reasons from multiple validators are concatenated by the caller, so each reason must stand alone without context from the others. Returning bare str reasons is DEPRECATED — the registry wraps them in ValidationReason and emits a deprecation warning; support will be removed in 2.0.

Return type:

list[ValidationReason]

Notes

Implementations must not raise on invalid input — all failures are reported via the returned list. Reason strings are surfaced verbatim in ValidationError messages, so phrasing and punctuation should be stable across releases.

class octodns.record.srv.SrvValueNotIpValidator(id, sets=None)[source]

Bases: ValueValidator

Checks that the SRV target field is not an IP address.

validate(value_cls, data, _type)[source]

Validate a record’s rdata values.

Parameters:
  • value_cls (type) – The concrete value class being validated (e.g. MxValue, _Ipv4Value). Validators that need access to value class-level attributes (e.g. VALID_ALGORITHMS, _address_type) should read them from value_cls. Per-instance configuration should live on self, not on value_cls.

  • data (list | tuple | str | dict) – The rdata to validate. For multi-value record types this is a list/tuple of value dicts or strings; for single-value types it may be a bare value. Most validators iterate data directly — when a validator needs to accept either form it should normalize with if not isinstance(data, (list, tuple)): data = (data,).

  • _type (str) – The record type string (e.g. 'MX', 'A'). Passed through to helpers like _check_target_format which format it into their reason strings.

Returns:

A list of ValidationReason objects describing validation failures — construct each with ValidationReason(reason, validator_id=self.id). Must return an empty list when the values are valid. Reasons from multiple validators are concatenated by the caller, so each reason must stand alone without context from the others. Returning bare str reasons is DEPRECATED — the registry wraps them in ValidationReason and emits a deprecation warning; support will be removed in 2.0.

Return type:

list[ValidationReason]

Notes

Implementations must not raise on invalid input — all failures are reported via the returned list. Reason strings are surfaced verbatim in ValidationError messages, so phrasing and punctuation should be stable across releases.

class octodns.record.srv.SrvValue(value)[source]

Bases: EqualityTupleMixin, dict

VALIDATORS = [<octodns.record.srv.SrvValueValidator object>, <octodns.record.srv.SrvValueRfcValidator object>, <octodns.record.srv.SrvValueNotIpValidator object>, <octodns.record.srv.SrvValueBestPracticeValidator object>]
classmethod _schema()[source]
classmethod parse_rdata_text(value)[source]
classmethod process(values)[source]
__init__(value)[source]
property priority
property weight
property port
property target
property data
property rdata_text
template(params)[source]
_equality_tuple()[source]
__repr__()[source]

Return repr(self).

class octodns.record.srv.SrvRecord(zone, name, data, source=None, context=None)[source]

Bases: ValuesMixin, Record

REFERENCES = ('https://datatracker.ietf.org/doc/html/rfc2782', 'https://datatracker.ietf.org/doc/html/rfc6335')
_type = 'SRV'
_value_type

alias of SrvValue

VALIDATORS = [<octodns.record.srv.SrvNameValidator object>, <octodns.record.srv.SrvNameRfcValidator object>]