| 1 |
NAME |
| 2 |
Validate::Net - Format validation for Net:: related strings |
| 3 |
|
| 4 |
SYNOPSIS |
| 5 |
use Validate::Net; |
| 6 |
|
| 7 |
my $good = '123.1.23.123'; |
| 8 |
my $bad = '123.432.21.12'; |
| 9 |
|
| 10 |
foreach ( $good, $bad ) { |
| 11 |
if ( Validate::Net->ip( $_ ) ) { |
| 12 |
print "'$_' is a valid ip\n"; |
| 13 |
} else { |
| 14 |
print "'$_' is not a valid ip address because:\n"; |
| 15 |
print Validate::Net->reason . "\n"; |
| 16 |
} |
| 17 |
} |
| 18 |
|
| 19 |
my $checker = Validate::Net->new( 'fast' ); |
| 20 |
unless ( $checker->host( 'foo.bar.blah' ) ) { |
| 21 |
print "You provided an invalid host"; |
| 22 |
} |
| 23 |
|
| 24 |
DESCRIPTION |
| 25 |
Validate::Net is a class designed to assist with the validation of |
| 26 |
internet related strings. It can be used to validate CGI forms, |
| 27 |
internally by modules, and in any place where you want to check that an |
| 28 |
internet related string is valid before handing it off to a Net::* |
| 29 |
modules. |
| 30 |
|
| 31 |
It allows you to catch errors early, and with more detailed error |
| 32 |
messages than you are likely to get further down in the Net::* modules. |
| 33 |
|
| 34 |
Whenever a test is false, you can access the reason through the "reason" |
| 35 |
method. |
| 36 |
|
| 37 |
METHODS |
| 38 |
host $host |
| 39 |
The "host" method is used to see if a value is a valid host. That is, it |
| 40 |
is either a domain name, or an ip address. |
| 41 |
|
| 42 |
domain $domain [, @options ] |
| 43 |
The "domain" method is used to check for a valid domain name according |
| 44 |
to RFC 1034. It additionally disallows two consective dashes 'foo--bar'. |
| 45 |
I've never seen it used, and it's probably a mistaken version of |
| 46 |
'foo-bar'. |
| 47 |
|
| 48 |
Depending on the options, additional checks may be made. No options are |
| 49 |
available at this time |
| 50 |
|
| 51 |
ip $ip |
| 52 |
The "ip" method is used to validate the format, of an ip address. If |
| 53 |
called with no options, it will just do a basic format check of the ip, |
| 54 |
checking that it conforms to the basic dotted quad format. |
| 55 |
|
| 56 |
Depending on the options, additional checks may be made. No options are |
| 57 |
available at this time |
| 58 |
|
| 59 |
port $port |
| 60 |
The "port" method is used to test for a valid port number. |
| 61 |
|
| 62 |
BUGS |
| 63 |
Unknown |
| 64 |
|
| 65 |
TO DO |
| 66 |
This module is not all that completed. Just enough to do some basics. |
| 67 |
Feel free to send me patches to add anything you like. |
| 68 |
|
| 69 |
Add support for networks |
| 70 |
Add "exists" support |
| 71 |
Add "dns" support for host names |
| 72 |
|
| 73 |
SUPPORT |
| 74 |
Bugs should be reported via the CPAN bug tracking system |
| 75 |
|
| 76 |
<http://rt.cpan.org/NoAuth/ReportBug.html?Queue=Validate-Net> |
| 77 |
|
| 78 |
For other inquiries, contact the author |
| 79 |
|
| 80 |
AUTHOR |
| 81 |
Adam Kennedy <[email protected]> |
| 82 |
|
| 83 |
SEE ALSO |
| 84 |
Net::* |
| 85 |
|
| 86 |
COPYRIGHT |
| 87 |
Copyright 2002 - 2008 Adam Kennedy. |
| 88 |
|
| 89 |
This program is free software; you can redistribute it and/or modify it |
| 90 |
under the same terms as Perl itself. |
| 91 |
|
| 92 |
The full text of the license can be found in the LICENSE file included |
| 93 |
with this module. |
| 94 |
|