octodns.record.target

Classes

TargetValueBestPracticeValidator(id[, sets])

Checks that a single-value target ends with a trailing . (i.e. is an absolute/fully-qualified name).

TargetValueValidator(id[, sets])

Validates a single-value target FQDN (CNAME, ALIAS, DNAME, PTR).

TargetsValueBestPracticeValidator(id[, sets])

Checks that each target in a multi-value record ends with a trailing . (i.e. is an absolute/fully-qualified name).

TargetsValueValidator(id[, sets])

Validates a list of target FQDNs (NS).

octodns.record.target._check_target_format(target, _type, key='value')[source]
octodns.record.target._check_target_trailing_dot(target, _type, key='value')[source]
class octodns.record.target.TargetValueValidator(id, sets=None)[source]

Bases: ValueValidator

Validates a single-value target FQDN (CNAME, ALIAS, DNAME, PTR).

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 human-readable reason strings describing validation failures. 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.

Return type:

list[str]

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

Bases: ValueValidator

Validates a list of target FQDNs (NS). Rejects empty lists.

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 human-readable reason strings describing validation failures. 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.

Return type:

list[str]

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

Bases: ValueValidator

Checks that a single-value target ends with a trailing . (i.e. is an absolute/fully-qualified name). Without the trailing dot, resolvers may append the host’s search domain, multiplying query traffic.

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 human-readable reason strings describing validation failures. 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.

Return type:

list[str]

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

Bases: ValueValidator

Checks that each target in a multi-value record ends with a trailing . (i.e. is an absolute/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 human-readable reason strings describing validation failures. 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.

Return type:

list[str]

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.target._TargetValue(v)[source]

Bases: str

VALIDATORS = [<octodns.record.target.TargetValueValidator object>, <octodns.record.target.TargetValueBestPracticeValidator object>]
classmethod parse_rdata_text(value)[source]
classmethod _schema()[source]
classmethod process(value)[source]
property rdata_text
template(params)[source]
class octodns.record.target._TargetsValue(v)[source]

Bases: str

VALIDATORS = [<octodns.record.target.TargetsValueValidator object>, <octodns.record.target.TargetsValueBestPracticeValidator object>]
classmethod parse_rdata_text(value)[source]
classmethod _schema()[source]
classmethod process(values)[source]
property rdata_text
template(params)[source]