|
FORMAT INTERFACEThis 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 <https://github.com/zonemaster/zonemaster/blob/master/docs/public/using/backend/rpcapi-reference.md#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>.
check_ip($value)Validates an IP address <https://github.com/zonemaster/zonemaster/blob/master/docs/public/using/backend/rpcapi-reference.md#ip-address>. check_profile($value, %profiles)Validates a profile name <https://github.com/zonemaster/zonemaster/blob/master/docs/public/using/backend/rpcapi-reference.md#profile-name>.
UNTAINT INTERFACEThis 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_typeAccepts the strings "MySQL", "PostgreSQL" and "SQLite", case-insensitively. untaint_ip_addressAccepts an IPv4 or IPv6 address. untaint_ipv4_addressAccepts an IPv4 address. untaint_ipv6_addressAccepts an IPv6 address. untaint_hostAccepts an LDH domain name or an IPv4 or IPv6 address. untaint_ldh_domainAccepts an LDH domain name. untaint_locale_tagAccepts a locale tag.
|