class HostnameValidator (View source)

Hostname validation service

Methods

__construct(ConfigurationManager $config)

No description

validate(mixed $hostname, bool $allowWildcard = false)

Validate hostname as FQDN

bool
isValid(string $hostname, bool $allowWildcard = false)

Simple validator for hostname validity

string
normalizeRecordName(string $name, string $zone)

Normalize a DNS record name by ensuring it is fully qualified with the zone name

static bool
endsWith(string $needle, string $haystack)

Matches end of string

Details

__construct(ConfigurationManager $config)

No description

Parameters

ConfigurationManager $config

ValidationResult validate(mixed $hostname, bool $allowWildcard = false)

Validate hostname as FQDN

Parameters

mixed $hostname

Hostname string

bool $allowWildcard

Allow wildcard (*) in hostname

Return Value

ValidationResult

Validation result with normalized hostname or error

bool isValid(string $hostname, bool $allowWildcard = false)

Simple validator for hostname validity

Parameters

string $hostname

Hostname to validate

bool $allowWildcard

Allow wildcard (*) in hostname

Return Value

bool

True if hostname is valid

string normalizeRecordName(string $name, string $zone)

Normalize a DNS record name by ensuring it is fully qualified with the zone name

Parameters

string $name

Name to normalize

string $zone

Zone name

Return Value

string

Normalized name

static bool endsWith(string $needle, string $haystack)

Matches end of string

Matches end of string (haystack) against another string (needle)

Parameters

string $needle
string $haystack

Return Value

bool

true if ends with specified string, otherwise false