File Coverage

blib/lib/Data/Validate/WithYAML/Plugin/EMail.pm
Criterion Covered Total %
statement 18 18 100.0
branch 3 4 75.0
condition n/a
subroutine 5 5 100.0
pod 1 1 100.0
total 27 28 96.4


line stmt bran cond sub pod time code
1             package Data::Validate::WithYAML::Plugin::EMail;
2              
3 3     3   1926702 use warnings;
  3         7  
  3         84  
4 3     3   13 use strict;
  3         5  
  3         85  
5              
6 3     3   14 use Carp;
  3         16  
  3         195  
7 3     3   17597 use Regexp::Common qw[Email::Address];
  3         17134  
  3         17  
8              
9             # ABSTRACT: Plugin for Data::Validate::WithYAML to check email addresses
10              
11             our $VERSION = '0.02';
12              
13             sub check {
14 11     11 1 4022 my ($class, $value) = @_;
15              
16 11 50       30 croak "no value to check" unless defined $value;
17              
18 11         14 my $return = 0;
19 11 100       60 if( $value =~ /($RE{Email}{Address})/ ){
20 8         1990 $return = 1;
21             }
22              
23 11         489 return $return;
24             }
25              
26              
27             1; # End of Data::Validate::WithYAML::Plugin::EMail
28              
29              
30              
31             __END__
32             =pod
33              
34             =head1 NAME
35              
36             Data::Validate::WithYAML::Plugin::EMail - Plugin for Data::Validate::WithYAML to check email addresses
37              
38             =head1 VERSION
39              
40             version 0.02
41              
42             =head1 SYNOPSIS
43              
44             use Data::Validate::WithYAML::Plugin::EMail;
45              
46             my $foo = Data::Validate::WithYAML::Plugin::EMail->check( 'test@exampl.com' );
47             ...
48            
49             # use the plugin via Data::Validate::WithYAML
50            
51             use Data::Validate::WithYAML;
52            
53             my $email = 'test@exampl.com';
54             my $validator = Data::Validate::WithYAML->new( 'test.yml' );
55             print "yes" if $validator->check( 'email', $email );
56              
57             test.yml
58              
59             ---
60             step1:
61             email:
62             plugin: EMail
63             type: required
64              
65             =head1 SUBROUTINES
66              
67             =head2 check
68              
69             =head1 AUTHOR
70              
71             Renee Baecker, C<< <module at renee-baecker.de> >>
72              
73             =head1 BUGS
74              
75             Please report any bugs or feature requests to
76             C<bug-data-validate-withyaml-plugin-email at rt.cpan.org>, or through the web interface at
77             L<http://rt.cpan.org/NoAuth/ReportBug.html?Queue=Data-Validate-WithYAML-Plugin-EMail>.
78             I will be notified, and then you'll automatically be notified of progress on
79             your bug as I make changes.
80              
81             =head1 SUPPORT
82              
83             You can find documentation for this module with the perldoc command.
84              
85             perldoc Data::Validate::WithYAML::Plugin::EMail
86              
87             You can also look for information at:
88              
89             =over 4
90              
91             =item * AnnoCPAN: Annotated CPAN documentation
92              
93             L<http://annocpan.org/dist/Data::Validate::WithYAML::Plugin::EMail>
94              
95             =item * CPAN Ratings
96              
97             L<http://cpanratings.perl.org/d/Data::Validate::WithYAML::Plugin::EMail>
98              
99             =item * RT: CPAN's request tracker
100              
101             L<http://rt.cpan.org/NoAuth/Bugs.html?Dist=Data::Validate::WithYAML::Plugin::EMail>
102              
103             =item * Search CPAN
104              
105             L<http://search.cpan.org/dist/Data::Validate::WithYAML::Plugin::EMail>
106              
107             =back
108              
109             =head1 ACKNOWLEDGEMENTS
110              
111             =head1 COPYRIGHT & LICENSE
112              
113             Copyright 2007 Renee Baecker, all rights reserved.
114              
115             This program is free software; you can redistribute it and/or modify it
116             under the same terms as Perl itself.
117              
118             =head1 AUTHOR
119              
120             Renee Baecker <module@renee-baecker.de>
121              
122             =head1 COPYRIGHT AND LICENSE
123              
124             This software is Copyright (c) 2012 by Renee Baecker.
125              
126             This is free software, licensed under:
127              
128             The Artistic License 2.0 (GPL Compatible)
129              
130             =head1 AUTHOR
131              
132             Renee Baecker <module@renee-baecker.de>
133              
134             =head1 COPYRIGHT AND LICENSE
135              
136             This software is Copyright (c) 2012 by Renee Baecker.
137              
138             This is free software, licensed under:
139              
140             The Artistic License 2.0 (GPL Compatible)
141              
142             =cut
143