Validate::Net(3pm)

πŸ“¦
version 0.6 Β· 2 versions
  • 0.6 Β· debian bookworm, debian trixie, ubuntu noble, ubuntu resolute, ubuntu stonking (latest)
  • 0.6 Β· ubuntu jammy
, in debian bookworm, debian trixie, ubuntu noble, ubuntu resolute, ubuntu stonking

πŸ’– Validate::Net πŸ’–

okay bestie, welcome to Validate::Net β€” the User Contributed Perl Documentation era of checking that your internet strings aren't lying to you. It's format validation for Net::-related strings, and it's lowkey the bouncer at the club door before your strings get handed off to the actual Net::* modules. 🫢


✨ NAME ✨

Validate::Net β€” format validation for Net::-related strings πŸ’…


πŸŽ€ SYNOPSIS πŸŽ€

  use Validate::Net;

  my $good = '123.1.23.123';
  my $bad = '123.432.21.12';

  foreach ( $good, $bad ) {
        if ( Validate::Net->ip( $_ ) ) {
                print "'$_' is a valid ip\n";
        } else {
                print "'$_' is not a valid ip address because:\n";
                print Validate::Net->reason . "\n";
        }
  }

  my $checker = Validate::Net->new( 'fast' );
  unless ( $checker->host( 'foo.bar.blah' ) ) {
        print "You provided an invalid host";
  }

see how it just… tells you why?? no more mystery. we love a transparent king. πŸ‘‘


🌸 DESCRIPTION 🌸

So Validate::Net is a class designed to assist with the validation of internet related strings. it's giving "helpful older sibling". You can use it to validate CGI forms, internally by modules, and in literally any place where you wanna check that an internet related string is valid before you hand it off to a Net::* module. πŸ’–

The whole point? It lets you catch errors early, and with way more detailed error messages than you're likely to get further down in the Net::* modules. no more digging through eight layers of stack trace just to find out you typed a dot wrong. 😭

Whenever a test is false, you can access the reason through the reason method. yes bestie, it tells you the tea. πŸ“


πŸ’… METHODS πŸ’…

host $host πŸ¦‹

The host method is used to see if a value is a valid host. That is, it is either a domain name, or an ip address. two for one, we love efficiency.

domain $domain [, @options ] 🌈

The domain method is used to check for a valid domain name according to RFC 1034. It additionally disallows two consective dashes 'foo--bar'. I've never seen it used, and it's probably a mistaken version of 'foo-bar'. πŸ’€ so yeah, that's a whole thing.

Depending on the options, additional checks may be made. No options are available at this time πŸ™ˆ β€” so like, it's the thought that counts.

ip $ip ⭐

The ip method is used to validate the format, of an ip address. If called with no options, it will just do a basic format check of the ip, checking that it conforms to the basic dotted quad format. four numbers, three dots, no nonsense.

Depending on the options, additional checks may be made. No options are available at this time 😌 β€” again, vibes only.

port $port 🧚

The port method is used to test for a valid port number. that's it, that's the whole method, and honestly? iconic.


πŸ’€ BUGS πŸ’€

Unknown. ngl bestie, that's either extremely reassuring or extremely ominous and I cannot tell which. πŸ”₯


πŸ‘‘ TO DO πŸ‘‘

This module is not all that completed. Just enough to do some basics. Feel free to send me patches to add anything you like. fr fr, the author said "send patches", that's a direct invitation. πŸ’Œ

  • Add support for networks 🌐
  • Add "exists" support πŸ”
  • Add "dns" support for host names πŸ“‘

🫢 SUPPORT 🫢

Bugs should be reported via the CPAN bug tracking system:

<http://rt.cpan.org/NoAuth/ReportBug.html?Queue=Validate-Net>

For other inquiries, contact the author. they're nice, I promise. ✨


🌟 AUTHOR 🌟

Adam Kennedy <adamk@cpan.org> β€” the main character, actually. πŸ‘‘


πŸ”₯ SEE ALSO πŸ”₯

Net::* β€” the whole extended universe. πŸ’œ


Copyright 2002 - 2008 Adam Kennedy. πŸ“

This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself.

The full text of the license can be found in the LICENSE file included with this module. πŸ“„


quick vibe check reminder: this page is from perl v5.36.0, dated 2022-11-19, and it's Validate::Net(3pm) β€” third section, manual page, perl-adjacent, no cap. πŸ’…βœ¨

okay that's the whole page bestie, go validate something and stay hydrated πŸ’–πŸŒΈπŸ¦‹

πŸ“¦ where this page comes from