Debian Codegraph @

README

raw ◀ ▶
Source reconstructed at patch state 0 of 1 — not the installed (fully patched) source.
1 Debian patch touch this file
1 NAME
2 Data::Validate::Email - common email validation methods
3
4 SYNOPSIS
5 use Data::Validate::Email qw(is_email is_email_rfc822);
6
7 if(is_email($suspect)){
8 print "Looks like an email address\n";
9 } elsif(is_email_rfc822($suspect)){
10 print "Doesn't much look like an email address, but passes rfc822\n";
11 } else {
12 print "Not an email address\n";
13 }
14
15 # or as an object
16 my $v = Data::Validate::Email->new();
17
18 die "not an email" unless ($v->is_email('foo'));
19
20 DESCRIPTION
21 This module collects common email validation routines to make input
22 validation, and untainting easier and more readable.
23
24 All functions return an untainted value if the test passes, and undef if
25 it fails. This means that you should always check for a defined status
26 explicitly. Don't assume the return will be true. (e.g.
27 is_username('0'))
28
29 The value to test is always the first (and often only) argument.
30
31 FUNCTIONS
32 new - constructor for OO usage
33 new([\%opts]);
34
35 *Description*
36 Returns a Data::Validator::Email object. This lets you access
37 all the validator function calls as methods without importing
38 them into your namespace or using the clumsy
39 Data::Validate::Email::function_name() format.
40
41 *Arguments*
42 An optional hash reference is retained and passed on to other
43 function calls in the Data::Validate module series. This module
44 does not utilize the extra data, but some child calls do. See
45 Data::Validate::Domain for an example.
46
47 *Returns*
48 Returns a Data::Validate::Email object
49
50 is_email - is the value a well-formed email address?
51 is_email($value);
52
53 *Description*
54 Returns the untainted address if the test value appears to be a
55 well-formed email address. This method tries to match real-world
56 addresses, rather than trying to support everything that rfc822
57 allows. (see is_email_rfc822 if you want the more permissive
58 behavior.)
59
60 In short, it pretty much looks for [email protected]. It
61 does not understand real names ("bob smith" <[email protected]>),
62 or other comments. It will not accept partially-qualified
63 addresses ('bob', or 'bob@machine')
64
65 *Arguments*
66
67 $value
68 The potential address to test.
69
70 *Returns*
71 Returns the untainted address on success, undef on failure.
72
73 *Notes, Exceptions, & Bugs*
74 This function does not make any attempt to check whether an
75 address is genuinely deliverable. It only looks to see that the
76 format is email-like.
77
78 The function accepts an optional hash reference as a second
79 argument to change the validation behavior. It is passed on
80 unchanged to Neil Neely's Data::Validate::Domain::is_domain()
81 function. See that module's documentation for legal values.
82
83 is_email_rfc822 - does the value look like an RFC 822 address?
84 is_email_rfc822($value);
85
86 *Description*
87 Returns the untainted address if the test value appears to be a
88 well-formed email address according to RFC822. Note that the
89 standard allows for a wide variety of address formats, including
90 ones with real names and comments.
91
92 In most cases you probably want to use is_email() instead. This
93 one will accept things that you probably aren't expecting
94 ('foo@bar', for example.)
95
96 *Arguments*
97
98 $value
99 The potential address to test.
100
101 *Returns*
102 Returns the untainted address on success, undef on failure.
103
104 *Notes, Exceptions, & Bugs*
105 This check uses Casey West's Email::Address module to do its
106 validation.
107
108 The function does not make any attempt to check whether an
109 address is genuinely deliverable. It only looks to see that the
110 format is email-like.
111
112 is_domain - does the value look like a domain name?
113 is_domain($value);
114
115 *Description*
116 Returns the untainted domain if the test value appears to be a
117 well-formed domain name. This test uses the same logic as
118 is_email(), rather than the somewhat more permissive pattern
119 specified by RFC822.
120
121 *Arguments*
122
123 $value
124 The potential domain to test.
125
126 *Returns*
127 Returns the untainted domain on success, undef on failure.
128
129 *Notes, Exceptions, & Bugs*
130 The function does not make any attempt to check whether a domain
131 is actually exists. It only looks to see that the format is
132 appropriate.
133
134 As of version 0.03, this is a direct pass-through to Neil
135 Neely's Data::Validate::Domain::is_domain() function.
136
137 The function accepts an optional hash reference as a second
138 argument to change the validation behavior. It is passed on
139 unchanged to Neil Neely's Data::Validate::Domain::is_domain()
140 function. See that module's documentation for legal values.
141
142 is_username - does the value look like a username?
143 is_username($value);
144
145 *Description*
146 Returns the untainted username if the test value appears to be a
147 well-formed username. More specifically, it tests to see if the
148 value is legal as the username component of an email address as
149 defined by is_email(). Note that this definition is more
150 restrictive than the one in RFC822.
151
152 *Arguments*
153
154 $value
155 The potential username to test.
156
157 *Returns*
158 Returns the untainted username on success, undef on failure.
159
160 *Notes, Exceptions, & Bugs*
161 The function does not make any attempt to check whether a
162 username actually exists on your system. It only looks to see
163 that the format is appropriate.
164
165 AUTHOR
166 Richard Sonnen <[email protected]>.
167
168 COPYRIGHT
169 Copyright (c) 2004 Richard Sonnen. All rights reserved.
170
171 This program is free software; you can redistribute it and/or modify it
172 under the same terms as Perl itself.
173