octodns.zone.validator

Classes

ZoneValidator(id[, sets])

Base class for zone-level validators.

ZoneValidatorRegistry()

class octodns.zone.validator.ValidationReason(reason, records=(), validator_id=None)[source]

Bases: str

A single validation failure reason.

Behaves as a plain str (its content is the bare, human-readable reason text) so existing code that compares or joins reasons as strings keeps working unchanged. In addition it carries the set of records the failure applies to and the validator_id of the validator that produced it, which __str__ uses to append context and , via: <validator_id> attribution — richer output that only appears where a caller explicitly renders with str(reason) (e.g. in ValidationError messages); plain string joins/comparisons see only the bare reason.

__init__(reason, records=(), validator_id=None)[source]
property lenient
__repr__()[source]

Return repr(self).

class octodns.zone.validator.ZoneValidator(id, sets=None)[source]

Bases: object

Base class for zone-level validators.

Subclasses override validate to return a list of ValidationReason objects describing any validation failures. An empty list indicates the zone is valid. The zone validator receives the fully assembled desired Zone and may examine any records within it. Because zone validators see the whole zone at once, they are suited for cross-record checks (e.g. requiring at least two MX values at the apex) that per-record validators cannot perform.

Every zone validator instance has a non-empty id — a short, stable, kebab-case identifier (e.g. 'multi-value-mx'). Config-registered validators receive their config key as id automatically.

When creating ValidationReason instances, pass validator_id=self.id so that error output can attribute each reason to its source validator.

A config-registered validator whose id matches a built-in’s replaces that built-in in the registry — e.g. defining a validators: entry named after a built-in mail zone validator swaps it out for a custom instance with different parameters (such as enforcing mail/no-mail).

__init__(id, sets=None)[source]
Parameters:
  • id – Non-empty identifier for this validator instance.

  • sets – Iterable of set names, or None to always activate.

validate(zone)[source]

Validate a fully populated zone.

Parameters:

zone – The Zone to validate.

Returns:

list[ValidationReason] of reason objects; empty when valid.

class octodns.zone.validator.ZoneValidatorRegistry[source]

Bases: object

log = <Logger Zone (WARNING)>
__init__()[source]
register(validator, replace=False)[source]
enable_sets(sets)[source]
enable(id)[source]
disable(validator_id)[source]
reset_active()[source]
registered()[source]
available_validators()[source]
process_zone(zone)[source]