class TXTRecordValidator implements DnsRecordValidatorInterface (View source)

TXT record validator

Validates TXT records according to:

  • RFC 1035: Domain Names - Implementation and Specification
  • RFC 7208: Sender Policy Framework (SPF) for Authorizing Use of Domains in Email
  • RFC 7489: Domain-based Message Authentication, Reporting, and Conformance (DMARC)

PowerDNS automatically splits TXT records longer than 255 bytes into multiple 255-byte chunks for wire transmission. This validator accepts long TXT records (up to 4096 bytes) and relies on PowerDNS to handle the protocol-level splitting.

Special handling is provided for specialized TXT record formats:

  • DMARC records at _dmarc. with v=DMARC1 content

Constants

private MAX_ZONE_TEMPLATE_LENGTH

Maximum length for zone template records (matches zone_templ_records.content VARCHAR(2048)).

Regular zone records use PowerDNS records.content VARCHAR(64000) and don't need this limit.

Methods

__construct(ConfigurationManager $config, int|null $maxLength = null)

No description

forZoneTemplate(ConfigurationManager $config)

Create a validator instance for zone template records Zone templates have a VARCHAR(2048) constraint on the content column

validate(string $content, string $name, mixed $prio, int|string|null $ttl, int $defaultTTL, mixed ...$args)

Validates TXT record content

Details

__construct(ConfigurationManager $config, int|null $maxLength = null)

No description

Parameters

ConfigurationManager $config
int|null $maxLength

Maximum content length (null = no limit for normal records)

static TXTRecordValidator forZoneTemplate(ConfigurationManager $config)

Create a validator instance for zone template records Zone templates have a VARCHAR(2048) constraint on the content column

Parameters

ConfigurationManager $config

Return Value

TXTRecordValidator

ValidationResult validate(string $content, string $name, mixed $prio, int|string|null $ttl, int $defaultTTL, mixed ...$args)

Validates TXT record content

Parameters

string $content

The content part of the record

string $name

The name part of the record

mixed $prio

The priority value (if applicable)

int|string|null $ttl

The TTL value

int $defaultTTL

The default TTL to use if not specified

mixed ...$args

Additional validator-specific parameters

Return Value

ValidationResult

ValidationResult containing validated data or error messages