|
NAMEData::Validate::Domain - Domain and host name validationVERSIONversion 0.15SYNOPSISuse Data::Validate::Domain qw(is_domain); # as a function my $test = is_domain($suspect); die "$test is not a domain" unless $test; # or die "$test is not a domain" unless is_domain($suspect, \%options); # or as an object my $v = Data::Validate::Domain->new(%options); die "$test is not a domain" unless $v->is_domain($suspect); DESCRIPTIONThis module offers a few subroutines for validating domain and host names.FUNCTIONSAll of the functions below are exported by default.All of the functions return an untainted value on success and a false value ("undef" or an empty list) on failure. In scalar context, you should check that the return value is defined, because something like "is_domain_label('0')" will return a defined but false value. The value to test is always the first (and often only) argument. Note that none of these functions test whether a domain or hostname is actually resolvable or reachable. Data::Validate::Domain->new()This method constructs a validation object. It accepts the following arguments:
is_domain($domain, \%options)This can be called as either a subroutine or a method. If called as a sub, you can pass any of the arguments accepted by the constructor as options. If called as a method, any additional options are ignored.This returns the untainted domain name if the given $domain is a valid domain. A dotted quad (such as 127.0.0.1) is not considered a domain and will return false. See Data::Validate::IP for IP Validation. Per RFC 1035, this sub does accept a value ending in a single period (i.e. "domain.com.") to be a valid domain. This is called an absolute domain name, and should be properly resolved by any DNS tool (tested with "dig", "ssh", and Net::DNS).
is_hostname($hostname, \%options)This can be called as either a subroutine or a method. If called as a sub, you can pass any of the arguments accepted by the constructor as options. If called as a method, any additional options are ignored.This returns the untainted hostname if the given $hostname is a valid hostname. Hostnames are not required to end in a valid TLD. is_domain_label($label, \%options)This can be called as either a subroutine or a method. If called as a sub, you can pass any of the arguments accepted by the constructor as options. If called as a method, any additional options are ignored.This returns the untainted label if the given $label is a valid label. A domain label is simply a single piece of a domain or hostname. For example, the "www.foo.com" hostname contains the labels "www", "foo", and "com". SEE ALSO[RFC 1034] [RFC 1035] [RFC 2181] [RFC 1123]
ACKNOWLEDGEMENTSThanks to Richard Sonnen <sonnen@richardsonnen.com> for writing the Data::Validate module.Thanks to Len Reed <lreed@levanta.com> for helping develop the options mechanism for Data::Validate modules. SUPPORTBugs may be submitted at <https://github.com/houseabsolute/Data-Validate-Domain/issues>.I am also usually active on IRC as 'autarch' on "irc://irc.perl.org". SOURCEThe source code repository for Data-Validate-Domain can be found at <https://github.com/houseabsolute/Data-Validate-Domain>.AUTHORS
CONTRIBUTORS
COPYRIGHT AND LICENSEThis software is copyright (c) 2021 by Neil Neely.This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself. The full text of the license can be found in the LICENSE file included with this distribution.
Visit the GSP FreeBSD Man Page Interface. |