FORMAT INTERFACE
This module contains a set of procedures for validating data types. The check_*
procedures take the value to validate and potential extra arguments and return either undef if the validation succeeded or the reason of the failure.
use Zonemaster::Backend::Validator qw( :format );
# prints "invalid value: The domain name character(s) are not supported"
if ( defined ( my $error = check_domain( 'not a domain' ) ) ) {
print "invalid value: $error\n";
} else {
print "value is valid\n";
}
# prints "value is valid"
if ( defined ( my $error = check_domain( 'zonemaster.net' ) ) ) {
print "invalid value: $error\n";
} else {
print "value is valid\n";
}
formats($config)
Returns a hashref to be used with the "format" method in JSON::Validator. The keys are the names of the custom formats, supports: domain
, language_tag
, ip
and profile
.
The method takes a Config object as argument.
check_domain(%value)
Validates a domain name.
check_language_tag($value, %locales)
Validates a https://github.com/zonemaster/zonemaster/blob/master/docs/public/using/backend/rpcapi-reference.md#language-tag.
- %locales
-
A hash of configured locales, as returned by Zonemaster::Backend::Config::LANGUAGE_locale.
check_ip($value)
Validates an IP address.
check_profile($value, %profiles)
Validates a profile name.
- %profiles
-
A hash of configured profiles, as returned by Zonemaster::Backend::Config::PUBLIC_PROFILES.
UNTAINT INTERFACE
This module contains a set of procedures for validating and untainting strings.
use Zonemaster::Backend::Validator qw( :untaint );
# prints "untainted: sqlite"
if ( defined ( my $value = untaint_engine_type( 'sqlite' ) ) ) {
print "untainted: $value\n";
}
# does not print anything
if ( defined ( my $value = untaint_engine_type( 'Excel' ) ) ) {
print "untainted: $value\n";
}
These procedures all take a possibly tainted single string argument. If the string is accepted an untainted copy of the string is returned.
untaint_engine_type
Accepts the strings "MySQL"
, "PostgreSQL"
and "SQLite"
, case-insensitively.
untaint_ip_address
Accepts an IPv4 or IPv6 address.
untaint_ipv4_address
Accepts an IPv4 address.
untaint_ipv6_address
Accepts an IPv6 address.
untaint_host
Accepts an LDH domain name or an IPv4 or IPv6 address.
untaint_ldh_domain
Accepts an LDH domain name.
untaint_locale_tag
Accepts a locale tag.