daily pastebin goal
11%
SHARE
TWEET

Data::Verifier

a guest Jan 30th, 2016 64 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. my $profile = {
  2.   is      => 'rw',
  3.   isa     => 'HashRef',
  4.   default => sub {
  5.     my $self = shift;
  6.     return {
  7.  
  8.       target => {
  9.         required   => 1,
  10.         type       => 'Str',
  11.         post_check => sub {
  12.           my $r = shift;
  13.           my $value = $r->get_value('target');
  14.           my $ok = $value =~ /all|email|id/ ? 1 : 0;
  15.           return $ok;
  16.         },
  17.       },
  18.  
  19.       email => {
  20.         required   => 0,
  21.         type       => 'Str',
  22.         post_check => sub {
  23.           my $r = shift;
  24.           use Email::Valid;
  25.           my $value = $r->get_value('email');
  26.           my $ok = Email::Valid->address($value) ? 1 : 0;                  
  27.           return $ok;
  28.         },
  29.       },    
  30.  
  31.       id => {
  32.         required   => 0,
  33.         type       => 'Int',
  34.       },
  35.    
  36.     },
  37.   },
  38. };
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top