octodns.record.base

Functions

unquote(s)

Classes

HealthcheckValidator(id[, sets])

Validates the optional octodns.healthcheck.protocol setting, if present, is one of the supported protocols.

NameValidator(id[, sets])

Validates record name and FQDN shape: rejects the legacy @ alias, enforces the 253-char total FQDN length and 63-char per-label length limits from RFC 1035, and flags empty/double-dot labels.

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

TtlValidator(id[, sets])

Validates that the record has a ttl and that it is a non-negative integer.

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

ValueTypeValidator()

Single-value variant of ValuesTypeValidator for records that use ValueMixin: passes data['value'] (or None) through to the value type's validators.

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

ValuesTypeValidator()

Bridges a record's _value_type into the record-level validation pipeline: pulls values/value from data, coerces to a list, and delegates to ValidatorRegistry.process_values, which handles both the legacy validate classmethod on the value class (for 3rd-party back-compat) and any active ValueValidator instances for the type.

octodns.record.base.unquote(s)[source]
class octodns.record.base.NameValidator(id, sets=None)[source]

Bases: RecordValidator

Validates record name and FQDN shape: rejects the legacy @ alias, enforces the 253-char total FQDN length and 63-char per-label length limits from RFC 1035, and flags empty/double-dot labels.

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.base.TtlValidator(id, sets=None)[source]

Bases: RecordValidator

Validates that the record has a ttl and that it is a non-negative integer.

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.base.HealthcheckValidator(id, sets=None)[source]

Bases: RecordValidator

Validates the optional octodns.healthcheck.protocol setting, if present, is one of the supported protocols.

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.base.ValueTypeValidator[source]

Bases: RecordValidator

Single-value variant of ValuesTypeValidator for records that use ValueMixin: passes data['value'] (or None) through to the value type’s validators.

__init__()[source]
Parameters:
  • id – Non-empty identifier for this validator instance. Used to look up the validator in the registry and to reference it in config (for enabling/disabling, etc.).

  • sets – Iterable of set names this validator belongs to, or None (the default) to always activate regardless of manager.enabled. Pass an explicit set such as sets={'legacy'} to opt into set-based filtering.

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.base.ValuesTypeValidator[source]

Bases: RecordValidator

Bridges a record’s _value_type into the record-level validation pipeline: pulls values/value from data, coerces to a list, and delegates to ValidatorRegistry.process_values, which handles both the legacy validate classmethod on the value class (for 3rd-party back-compat) and any active ValueValidator instances for the type.

__init__()[source]
Parameters:
  • id – Non-empty identifier for this validator instance. Used to look up the validator in the registry and to reference it in config (for enabling/disabling, etc.).

  • sets – Iterable of set names this validator belongs to, or None (the default) to always activate regardless of manager.enabled. Pass an explicit set such as sets={'legacy'} to opt into set-based filtering.

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.base.Record(zone, name, data, source=None, context=None)[source]

Bases: EqualityTupleMixin

log = <Logger Record (WARNING)>
REFERENCES = ('https://datatracker.ietf.org/doc/html/rfc1035', 'https://datatracker.ietf.org/doc/html/rfc1123', 'https://datatracker.ietf.org/doc/html/rfc2181', 'https://datatracker.ietf.org/doc/html/rfc4592', 'https://datatracker.ietf.org/doc/html/rfc5890')
_CLASSES = {'A': <class 'octodns.record.a.ARecord'>, 'AAAA': <class 'octodns.record.aaaa.AaaaRecord'>, 'ALIAS': <class 'octodns.record.alias.AliasRecord'>, 'CAA': <class 'octodns.record.caa.CaaRecord'>, 'CNAME': <class 'octodns.record.cname.CnameRecord'>, 'DNAME': <class 'octodns.record.dname.DnameRecord'>, 'DS': <class 'octodns.record.ds.DsRecord'>, 'HTTPS': <class 'octodns.record.https.HttpsRecord'>, 'LOC': <class 'octodns.record.loc.LocRecord'>, 'MX': <class 'octodns.record.mx.MxRecord'>, 'NAPTR': <class 'octodns.record.naptr.NaptrRecord'>, 'NS': <class 'octodns.record.ns.NsRecord'>, 'OPENPGPKEY': <class 'octodns.record.openpgpkey.OpenpgpkeyRecord'>, 'PTR': <class 'octodns.record.ptr.PtrRecord'>, 'SPF': <class 'octodns.record.spf.SpfRecord'>, 'SRV': <class 'octodns.record.srv.SrvRecord'>, 'SSHFP': <class 'octodns.record.sshfp.SshfpRecord'>, 'SVCB': <class 'octodns.record.svcb.SvcbRecord'>, 'TLSA': <class 'octodns.record.tlsa.TlsaRecord'>, 'TXT': <class 'octodns.record.txt.TxtRecord'>, 'URI': <class 'octodns.record.uri.UriRecord'>, 'URLFWD': <class 'octodns.record.urlfwd.UrlfwdRecord'>}
validators = <octodns.record.validator.ValidatorRegistry object>
classmethod register_type(_class, _type=None)[source]
classmethod registered_types()[source]
classmethod register_validator(validator, types=None, replace=False)[source]
classmethod enable_validators(sets)[source]
classmethod enable_validator(id, types=None)[source]
classmethod disable_validator(validator_id, types=None)[source]
classmethod registered_validators()[source]
classmethod available_validators()[source]
classmethod new(zone, name, data, source=None, lenient=False)[source]
classmethod _process_validators(name, fqdn, data, disabled=None)[source]
classmethod validate(name, fqdn, data, disabled=None)[source]
classmethod from_rrs(zone, rrs, lenient=False, source=None)[source]
classmethod parse_rdata_texts(rdatas)[source]
__init__(zone, name, data, source=None, context=None)[source]
property _octodns
_data()[source]
property data
property fqdn
property decoded_fqdn
property ignored
property excluded
property included
healthcheck_host(value=None)[source]
property healthcheck_path
property healthcheck_protocol
property healthcheck_port
property lenient
changes(other, target)[source]
copy(zone=None, value=None, values=None, lenient=True)[source]
_equality_tuple()[source]
__repr__()[source]

Return repr(self).

octodns.record.base._process_value_validators(value_type, values, _type, disabled=None)[source]
class octodns.record.base.ValuesMixin(zone, name, data, source=None, context=None)[source]

Bases: object

VALIDATORS = [<octodns.record.base.ValuesTypeValidator object>]
classmethod data_from_rrs(rrs)[source]
__init__(zone, name, data, source=None, context=None)[source]
changes(other, target)[source]
_data()[source]
property rr_values
property rrs
__repr__()[source]

Return repr(self).

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

Bases: object

VALIDATORS = [<octodns.record.base.ValueTypeValidator object>]
classmethod data_from_rrs(rrs)[source]
__init__(zone, name, data, source=None, context=None)[source]
changes(other, target)[source]
_data()[source]
property rrs
__repr__()[source]

Return repr(self).