.\" Automatically generated by Pod::Man 4.09 (Pod::Simple 3.35) .\" .\" Standard preamble: .\" ======================================================================== .de Sp \" Vertical space (when we can't use .PP) .if t .sp .5v .if n .sp .. .de Vb \" Begin verbatim text .ft CW .nf .ne \\$1 .. .de Ve \" End verbatim text .ft R .fi .. .\" Set up some character translations and predefined strings. \*(-- will .\" give an unbreakable dash, \*(PI will give pi, \*(L" will give a left .\" double quote, and \*(R" will give a right double quote. \*(C+ will .\" give a nicer C++. Capital omega is used to do unbreakable dashes and .\" therefore won't be available. \*(C` and \*(C' expand to `' in nroff, .\" nothing in troff, for use with C<>. .tr \(*W- .ds C+ C\v'-.1v'\h'-1p'\s-2+\h'-1p'+\s0\v'.1v'\h'-1p' .ie n \{\ . ds -- \(*W- . ds PI pi . if (\n(.H=4u)&(1m=24u) .ds -- \(*W\h'-12u'\(*W\h'-12u'-\" diablo 10 pitch . if (\n(.H=4u)&(1m=20u) .ds -- \(*W\h'-12u'\(*W\h'-8u'-\" diablo 12 pitch . ds L" "" . ds R" "" . ds C` "" . ds C' "" 'br\} .el\{\ . ds -- \|\(em\| . ds PI \(*p . ds L" `` . ds R" '' . ds C` . ds C' 'br\} .\" .\" Escape single quotes in literal strings from groff's Unicode transform. .ie \n(.g .ds Aq \(aq .el .ds Aq ' .\" .\" If the F register is >0, we'll generate index entries on stderr for .\" titles (.TH), headers (.SH), subsections (.SS), items (.Ip), and index .\" entries marked with X<> in POD. Of course, you'll have to process the .\" output yourself in some meaningful fashion. .\" .\" Avoid warning from groff about undefined register 'F'. .de IX .. .if !\nF .nr F 0 .if \nF>0 \{\ . de IX . tm Index:\\$1\t\\n%\t"\\$2" .. . if !\nF==2 \{\ . nr % 0 . nr F 2 . \} .\} .\" ======================================================================== .\" .IX Title "Email 3pm" .TH Email 3pm "2018-07-22" "perl v5.26.2" "User Contributed Perl Documentation" .\" For nroff, turn off justification. Always turn off hyphenation; it makes .\" way too many mistakes in technical documents. .if n .ad l .nh .SH "NAME" Data::Validate::Email \- common email validation methods .SH "SYNOPSIS" .IX Header "SYNOPSIS" .Vb 1 \& use Data::Validate::Email qw(is_email is_email_rfc822); \& \& if(is_email($suspect)){ \& print "Looks like an email address\en"; \& } elsif(is_email_rfc822($suspect)){ \& print "Doesn\*(Aqt much look like an email address, but passes rfc822\en"; \& } else { \& print "Not an email address\en"; \& } \& \& # or as an object \& my $v = Data::Validate::Email\->new(); \& \& die "not an email" unless ($v\->is_email(\*(Aqfoo\*(Aq)); .Ve .SH "DESCRIPTION" .IX Header "DESCRIPTION" This module collects common email validation routines to make input validation, and untainting easier and more readable. .PP All functions return an untainted value if the test passes, and undef if it fails. This means that you should always check for a defined status explicitly. Don't assume the return will be true. (e.g. is_username('0')) .PP The value to test is always the first (and often only) argument. .SH "FUNCTIONS" .IX Header "FUNCTIONS" .IP "\fBnew\fR \- constructor for \s-1OO\s0 usage" 4 .IX Item "new - constructor for OO usage" .Vb 1 \& new([\e%opts]); .Ve .RS 4 .IP "\fIDescription\fR" 4 .IX Item "Description" Returns a Data::Validator::Email object. This lets you access all the validator function calls as methods without importing them into your namespace or using the clumsy \&\fIData::Validate::Email::function_name()\fR format. .IP "\fIArguments\fR" 4 .IX Item "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. .IP "\fIReturns\fR" 4 .IX Item "Returns" Returns a Data::Validate::Email object .RE .RS 4 .RE .IP "\fBis_email\fR \- is the value a well-formed email address?" 4 .IX Item "is_email - is the value a well-formed email address?" .Vb 1 \& is_email($value); .Ve .RS 4 .IP "\fIDescription\fR" 4 .IX Item "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.) .Sp In short, it pretty much looks for something@something.tld. It does not understand real names (\*(L"bob smith\*(R" ), or other comments. It will not accept partially-qualified addresses ('bob', or 'bob@machine') .IP "\fIArguments\fR" 4 .IX Item "Arguments" .RS 4 .PD 0 .ie n .IP "$value" 4 .el .IP "\f(CW$value\fR" 4 .IX Item "$value" .PD The potential address to test. .RE .RS 4 .RE .IP "\fIReturns\fR" 4 .IX Item "Returns" Returns the untainted address on success, undef on failure. .IP "\fINotes, Exceptions, & Bugs\fR" 4 .IX Item "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. .Sp 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 \&\fIData::Validate::Domain::is_domain()\fR function. See that module's documentation for legal values. .RE .RS 4 .RE .IP "\fBis_email_rfc822\fR \- does the value look like an \s-1RFC 822\s0 address?" 4 .IX Item "is_email_rfc822 - does the value look like an RFC 822 address?" .Vb 1 \& is_email_rfc822($value); .Ve .RS 4 .IP "\fIDescription\fR" 4 .IX Item "Description" Returns the untainted address if the test value appears to be a well-formed email address according to \s-1RFC822.\s0 Note that the standard allows for a wide variety of address formats, including ones with real names and comments. .Sp In most cases you probably want to use \fIis_email()\fR instead. This one will accept things that you probably aren't expecting ('foo@bar', for example.) .IP "\fIArguments\fR" 4 .IX Item "Arguments" .RS 4 .PD 0 .ie n .IP "$value" 4 .el .IP "\f(CW$value\fR" 4 .IX Item "$value" .PD The potential address to test. .RE .RS 4 .RE .IP "\fIReturns\fR" 4 .IX Item "Returns" Returns the untainted address on success, undef on failure. .IP "\fINotes, Exceptions, & Bugs\fR" 4 .IX Item "Notes, Exceptions, & Bugs" This check uses Email::Address::XS module to do its validation. .Sp 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. .RE .RS 4 .RE .IP "\fBis_domain\fR \- does the value look like a domain name?" 4 .IX Item "is_domain - does the value look like a domain name?" .Vb 1 \& is_domain($value); .Ve .RS 4 .IP "\fIDescription\fR" 4 .IX Item "Description" Returns the untainted domain if the test value appears to be a well-formed domain name. This test uses the same logic as \fIis_email()\fR, rather than the somewhat more permissive pattern specified by \s-1RFC822.\s0 .IP "\fIArguments\fR" 4 .IX Item "Arguments" .RS 4 .PD 0 .ie n .IP "$value" 4 .el .IP "\f(CW$value\fR" 4 .IX Item "$value" .PD The potential domain to test. .RE .RS 4 .RE .IP "\fIReturns\fR" 4 .IX Item "Returns" Returns the untainted domain on success, undef on failure. .IP "\fINotes, Exceptions, & Bugs\fR" 4 .IX Item "Notes, Exceptions, & Bugs" The function does not make any attempt to check whether a domain is actually exists. It only looks to see that the format is appropriate. .Sp As of version 0.03, this is a direct pass-through to Neil Neely's \&\fIData::Validate::Domain::is_domain()\fR function. .Sp 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 \&\fIData::Validate::Domain::is_domain()\fR function. See that module's documentation for legal values. .RE .RS 4 .RE .IP "\fBis_username\fR \- does the value look like a username?" 4 .IX Item "is_username - does the value look like a username?" .Vb 1 \& is_username($value); .Ve .RS 4 .IP "\fIDescription\fR" 4 .IX Item "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 \fIis_email()\fR. Note that this definition is more restrictive than the one in \s-1RFC822.\s0 .IP "\fIArguments\fR" 4 .IX Item "Arguments" .RS 4 .PD 0 .ie n .IP "$value" 4 .el .IP "\f(CW$value\fR" 4 .IX Item "$value" .PD The potential username to test. .RE .RS 4 .RE .IP "\fIReturns\fR" 4 .IX Item "Returns" Returns the untainted username on success, undef on failure. .IP "\fINotes, Exceptions, & Bugs\fR" 4 .IX Item "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. .RE .RS 4 .RE .SH "AUTHOR" .IX Header "AUTHOR" Richard Sonnen <\fIsonnen@richardsonnen.com\fR>. .SH "COPYRIGHT" .IX Header "COPYRIGHT" Copyright (c) 2004 Richard Sonnen. All rights reserved. .PP This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself.