octodns.zone.validator
Classes
|
Base class for zone-level validators. |
- class octodns.zone.validator.ValidationReason(reason, records=(), validator_id=None)[source]
Bases:
strA 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 ofrecordsthe failure applies to and thevalidator_idof 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 withstr(reason)(e.g. inValidationErrormessages); plain string joins/comparisons see only the bare reason.- property lenient
- class octodns.zone.validator.ZoneValidator(id, sets=None)[source]
Bases:
objectBase class for zone-level validators.
Subclasses override
validateto 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 asidautomatically.When creating
ValidationReasoninstances, passvalidator_id=self.idso 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).