octodns.record.mx

Classes

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

MxValue(value)

MxValueBestPracticeValidator(id[, sets])

Checks that the MX exchange field ends with a trailing . (fully-qualified name).

MxValueNotIpValidator(id[, sets])

Checks that the MX exchange field is not an IP address.

MxValueRfcValidator(id[, sets])

Strict MX rdata validator per RFC 5321 and RFC 7505.

MxValueValidator(id[, sets])

Validates MX rdata: an integer-parsable preference (or legacy priority alias) and a valid exchange FQDN (or legacy value alias).

class octodns.record.mx.MxValueValidator(id, sets=None)[source]

Bases: ValueValidator

Validates MX rdata: an integer-parsable preference (or legacy priority alias) and a valid exchange FQDN (or legacy value alias).

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

Bases: ValueValidator

Strict MX rdata validator per RFC 5321 and RFC 7505.

  • preference must be in [0, 65535].

  • When exchange is ".", preference must be 0 (null MX per RFC 7505 §3).

  • When exchange is not ".", it must be a valid FQDN.

Enabled as part of the strict validator set:

manager:
  enabled:
    - strict
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.mx.MxValueBestPracticeValidator(id, sets=None)[source]

Bases: ValueValidator

Checks that the MX exchange field ends with a trailing . (fully-qualified name). Without the trailing dot resolvers may append the host search domain, causing extra lookups.

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

Bases: ValueValidator

Checks that the MX exchange 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 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.mx.MxValue(value)[source]

Bases: EqualityTupleMixin, dict

VALIDATORS = [<octodns.record.mx.MxValueValidator object>, <octodns.record.mx.MxValueRfcValidator object>, <octodns.record.mx.MxValueNotIpValidator object>, <octodns.record.mx.MxValueBestPracticeValidator object>]
classmethod _schema()[source]
classmethod parse_rdata_text(value)[source]
classmethod process(values)[source]
__init__(value)[source]
property preference
property exchange
property data
property rdata_text
template(params)[source]
_equality_tuple()[source]
__repr__()[source]

Return repr(self).

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

Bases: ValuesMixin, Record

REFERENCES = ('https://datatracker.ietf.org/doc/html/rfc1035', 'https://datatracker.ietf.org/doc/html/rfc5321', 'https://datatracker.ietf.org/doc/html/rfc7505')
_type = 'MX'
_value_type

alias of MxValue