Se ha denunciado esta presentación.
Utilizamos tu perfil de LinkedIn y tus datos de actividad para personalizar los anuncios y mostrarte publicidad más relevante. Puedes cambiar tus preferencias de publicidad en cualquier momento.

FormValidator::LazyWay で検証ルールをまとめよう

3.127 visualizaciones

Publicado el

CPAN モジュールの FormValidator::LazyWay について

Publicado en: Tecnología
  • Was a little hesitant about using ⇒⇒⇒WRITE-MY-PAPER.net ⇐⇐⇐ at first, but am very happy that I did. The writer was able to write my paper by the deadline and it was very well written. So guys don’t hesitate to use it.
       Responder 
    ¿Estás seguro?    No
    Tu mensaje aparecerá aquí
  • Dating direct: ♥♥♥ http://bit.ly/2F90ZZC ♥♥♥
       Responder 
    ¿Estás seguro?    No
    Tu mensaje aparecerá aquí
  • Sé el primero en recomendar esto

FormValidator::LazyWay で検証ルールをまとめよう

  1. 1. my $config = { rules => [ 'Email', 'String' ], setting => { strict => { email => { rule => ['Email#email'] }, password => { rule => [ { 'String#length' => { 'min' => '4', 'max' => '12' } }, 'String#ascii' ] }, } }, lang => 'ja', labels => { ja => { email => ' ', password => ' ' } }, };
  2. 2. use FormValidator::LazyWay; my $fv = FormValidator::LazyWay->new($config); my $result = $fv->check($q, { required => [qw/nickname email password/], optional => [qw/message/] });
  3. 3. my $result = $fv->check($q, { required => [qw/title/], optional => [qw/body/] }); my $result = $fv->check($q, { optional => [qw/title body/] });
  4. 4. my $result = $fv->check($q, { required => [qw/nickname email password/], optional => [qw/message/] }); if ( $result->has_error ) { print Dumper $result->error_message; # output #$VAR1 = { # 'email' => ' ', # 'password' => ' 4 12 ' #}; } else { # OK! print Dumper $result->valid; }
  5. 5. setting: my $result = $fv->check( $cgi, strict: { required => [qw/email/], email: level => { email => 'loose' rule: } - Email#email } loose: ); email: rule: - Email#email_loose
  6. 6. setting: regexp_map: '_id$': rule: - Number#integer
  7. 7. merge: date: format: "%04d-%02d-%02d" fields: - year - month - day strict: date: rule: - DateTime#date
  8. 8. setting: strict: date: filter: - Unify#hyphen rule: - DateTime#date fix: - DateTime#format: - '%Y-%m-%d'
  9. 9. my $result = $fv->check($q, { required => [qw/nickname email password/], optional => [qw/message/] }); if ( $result->has_error ) { print Dumper $res->error_message; } # DateTime print $result->valid->{date};
  10. 10. my $result = $fv->check($q, { required => [qw/nickname email password/], optional => [qw/message/] }); $result->custom_invalid( 'email_not_unique', ' ' ); if ( $res->has_error ) { print Dumper $res->error_message; }
  11. 11. my $wants_to_validate = { nickname => 'vkgtaro', email => 'vkg.taro@gmail.com', password => 'mypass', }; my $result = $fv->check($q, { required => [qw/nickname email password/], optional => [qw/message/], custom_parameters => $wants_to_validate, });
  12. 12. messages : ja : rule_message : __field__ __rule__ rule : Email#email : String#length : $_[min] $_[max]
  13. 13. messages : ja : rule_message : __field__ __rule__ rule : Email#email : String#length : $_[min] $_[max]

×