Email(3pm)
π NAME π
ok so bestie, <rainbow>Data::Validate::Email</rainbow> β it's your little toolbox of common email validation methods, and honestly? iconic. π
β¨ SYNOPSIS β¨
use Data::Validate::Email qw(is_email is_email_rfc822);
if(is_email($suspect)){
print "Looks like an email address\n";
} elsif(is_email_rfc822($suspect)){
print "Doesn't much look like an email address, but passes rfc822\n";
} else {
print "Not an email address\n";
}
# or as an object
my $v = Data::Validate::Email->new();
die "not an email" unless ($v->is_email('foo'));
like, look at that. two ways to do it: import the functions OR go full object-mode main character. both slay. π«Ά
π¦ DESCRIPTION π¦
This module is a lil collection of common email validation routines, and its whole thing is making input validation and untainting easier and more readable. periodt. π
ok so here's the tea, and this part is IMPORTANT: every function returns an untainted value if the test passes, and undef if it fails. So like... you should ALWAYS check for a defined status explicitly. do not just assume the return is gonna be true, bestie. I'm so serious. (e.g. is_username('0') β see how that could go wrong?? yeah. π)
The value to test is always the first (and often only) argument. easy. π
π₯ FUNCTIONS π₯
πΈ new β constructor for OO usage πΈ
new([\%opts]);
Description
Returns a Data::Validator::Email object. (yes, the docs really say Data::Validator::Email there β I'm just telling you what it says, don't come for me π) This lets you access all the validator function calls as methods, without importing them into your namespace or dealing with the clumsy Data::Validate::Email::function_name() format. no cap, way cuter as a method. β¨
Arguments
An optional hash reference is retained and passed on to other function calls in the Data::Validate module series. This module does not utilize the extra data, but some child calls do. See Data::Validate::Domain for an example. π
Returns
Returns a Data::Validate::Email object. look at you, you got an object. π
π is_email β is the value a well-formed email address? π
is_email($value);
Description
Returns the untainted address if the test value appears to be a well-formed email address. This method tries to match real-world addresses, rather than trying to support everything that rfc822 allows. (see is_email_rfc822 if you want the more permissive behavior β that one's the chaotic one, iykyk.)
In short, it pretty much looks for something@something.tld. It does not understand real names ("bob smith" <bsmith@test.com>), or other comments. It will not accept partially-qualified addresses ('bob', or 'bob@machine'). nope nope nope. π
Arguments
$valueβ the potential address to test. give it to me. π
Returns
Returns the untainted address on success, undef on failure.
Notes, Exceptions, & Bugs
This function does not make any attempt to check whether an address is genuinely deliverable. It only looks to see that the format is email-like. so like... it's a vibe check, not a mail carrier. π
The function accepts an optional hash reference as a second argument to change the validation behavior. It is passed on unchanged to Neil Neely's Data::Validate::Domain::is_domain() function. See that module's documentation for legal values. π
π is_email_rfc822 β does the value look like an RFC 822 address? π
is_email_rfc822($value);
Description
Returns the untainted address if the test value appears to be a well-formed email address according to RFC822. Note that the standard allows for a wide variety of address formats, including ones with real names and comments. it's giving permissive. it's giving yes-queen. β¨
In most cases you probably want to use is_email() instead. This one will accept things that you probably aren't expecting ('foo@bar', for example.) so like, be aware. π
Arguments
$valueβ the potential address to test. π
Returns
Returns the untainted address on success, undef on failure.
Notes, Exceptions, & Bugs
This check uses the Email::Address::XS module to do its validation. shoutout. π«Ά
The function does not make any attempt to check whether an address is genuinely deliverable. It only looks to see that the format is email-like.
π§ is_domain β does the value look like a domain name? π§
is_domain($value);
Description
Returns the untainted domain if the test value appears to be a well-formed domain name. This test uses the same logic as is_email(), rather than the somewhat more permissive pattern specified by RFC822. so it's the stricter sibling. π
Arguments
$valueβ the potential domain to test. πΈ
Returns
Returns the untainted domain on success, undef on failure.
Notes, Exceptions, & Bugs
The function does not make any attempt to check whether a domain actually exists. It only looks to see that the format is appropriate. (grammar check, not a background check, bestie. π)
As of version 0.03, this is a direct pass-through to Neil Neely's Data::Validate::Domain::is_domain() function. π
The function accepts an optional hash reference as a second argument to change the validation behavior. It is passed on unchanged to Neil Neely's Data::Validate::Domain::is_domain() function. See that module's documentation for legal values.
β is_username β does the value look like a username? β
is_username($value);
Description
Returns the untainted username if the test value appears to be a well-formed username. More specifically, it tests to see if the value is legal as the username component of an email address as defined by is_email(). Note that this definition is more restrictive than the one in RFC822. she's picky and honestly? respect. π
Arguments
$valueβ the potential username to test. π
Returns
Returns the untainted username on success, undef on failure.
Notes, Exceptions, & Bugs
The function does not make any attempt to check whether a username actually exists on your system. It only looks to see that the format is appropriate. no stalking, just formatting. π
π AUTHOR π
Richard Sonnen <sonnen@richardsonnen.com>. π«Ά
π COPYRIGHT π
Copyright (c) 2004 Richard Sonnen. All rights reserved.
This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself.
ok and that's the whole page bestie!! this one came from the User Contributed Perl Documentation for3pmmanual section, section 3, perl modules, you know the vibe π ), and the footer saidperl v5.26.2with a date of2018-07-22. that's a 2018 girlie but she still ate. go validate some emails, ily, mwah πβ¨π
π¦ where this page comes from
- debian bookworm: libdata-validate-email-perl 0.06-2 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- debian trixie: libdata-validate-email-perl 0.06-2 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- ubuntu jammy: libdata-validate-email-perl 0.06-2 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- ubuntu noble: libdata-validate-email-perl 0.06-2 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms