SlideShare una empresa de Scribd logo
1 de 48
Descargar para leer sin conexión
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 => '         '
          }
     },
};
use FormValidator::LazyWay;

my $fv = FormValidator::LazyWay->new($config);
my $result = $fv->check($q, {
    required => [qw/nickname email password/],
    optional => [qw/message/]
});
my $result = $fv->check($q, {
    required => [qw/title/],
    optional => [qw/body/]
});




my $result = $fv->check($q, {
    optional => [qw/title body/]
});
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;
}
setting:                      my $result = $fv->check( $cgi,
  strict:                         {   required => [qw/email/],
    email:                            level => {
                                          email => 'loose'
      rule:
                                      }
        - Email#email
                                  }
  loose:                      );
    email:
      rule:
        - Email#email_loose
setting:
  regexp_map:
    '_id$':
      rule:
         - Number#integer
merge:
  date:
    format: "%04d-%02d-%02d"
    fields:
       - year
       - month
       - day
strict:
  date:
    rule:
       - DateTime#date
setting:
  strict:
    date:
      filter:
         - Unify#hyphen
      rule:
         - DateTime#date
      fix:
         - DateTime#format:
             - '%Y-%m-%d'
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};
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;
}
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,
});
messages :
    ja :
         rule_message : __field__     __rule__
        rule :
            Email#email   :
            String#length : $_[min]              $_[max]
messages :
    ja :
         rule_message : __field__     __rule__
        rule :
            Email#email   :
            String#length : $_[min]              $_[max]
FormValidator::LazyWay で検証ルールをまとめよう
FormValidator::LazyWay で検証ルールをまとめよう
FormValidator::LazyWay で検証ルールをまとめよう

Más contenido relacionado

La actualidad más candente

PHP Lecture 4 - Working with form, GET and Post Methods
PHP Lecture 4 - Working with form, GET and Post MethodsPHP Lecture 4 - Working with form, GET and Post Methods
PHP Lecture 4 - Working with form, GET and Post MethodsAl-Mamun Sarkar
 
First step of Performance Tuning
First step of Performance TuningFirst step of Performance Tuning
First step of Performance Tuningrisou
 
PHP Lecture 6 - Php file uploading
PHP Lecture 6 - Php file uploadingPHP Lecture 6 - Php file uploading
PHP Lecture 6 - Php file uploadingAl-Mamun Sarkar
 
Dependency Injection
Dependency InjectionDependency Injection
Dependency InjectionRifat Nabi
 
[Php] navigations
[Php] navigations[Php] navigations
[Php] navigationsThai Pham
 
ETL for Pros: Getting Data Into MongoDB
ETL for Pros: Getting Data Into MongoDBETL for Pros: Getting Data Into MongoDB
ETL for Pros: Getting Data Into MongoDBMongoDB
 
introduction to Django in five slides
introduction to Django in five slides introduction to Django in five slides
introduction to Django in five slides Dan Chudnov
 
MongoDB a document store that won't let you down.
MongoDB a document store that won't let you down.MongoDB a document store that won't let you down.
MongoDB a document store that won't let you down.Nurul Ferdous
 
"Powerful Analysis with the Aggregation Pipeline (Tutorial)"
"Powerful Analysis with the Aggregation Pipeline (Tutorial)""Powerful Analysis with the Aggregation Pipeline (Tutorial)"
"Powerful Analysis with the Aggregation Pipeline (Tutorial)"MongoDB
 
Path::Tiny
Path::TinyPath::Tiny
Path::Tinywaniji
 
MongoDB World 2019: Aggregation Pipeline Power++: How MongoDB 4.2 Pipeline Em...
MongoDB World 2019: Aggregation Pipeline Power++: How MongoDB 4.2 Pipeline Em...MongoDB World 2019: Aggregation Pipeline Power++: How MongoDB 4.2 Pipeline Em...
MongoDB World 2019: Aggregation Pipeline Power++: How MongoDB 4.2 Pipeline Em...MongoDB
 
MongoDB .local Bengaluru 2019: Aggregation Pipeline Power++: How MongoDB 4.2 ...
MongoDB .local Bengaluru 2019: Aggregation Pipeline Power++: How MongoDB 4.2 ...MongoDB .local Bengaluru 2019: Aggregation Pipeline Power++: How MongoDB 4.2 ...
MongoDB .local Bengaluru 2019: Aggregation Pipeline Power++: How MongoDB 4.2 ...MongoDB
 
MongoDBと位置情報 ~地理空間インデックスの紹介
MongoDBと位置情報 ~地理空間インデックスの紹介MongoDBと位置情報 ~地理空間インデックスの紹介
MongoDBと位置情報 ~地理空間インデックスの紹介Koji Iwazaki
 
San Francisco Java User Group
San Francisco Java User GroupSan Francisco Java User Group
San Francisco Java User Groupkchodorow
 
8. Php MongoDB stergerea unui document
8. Php MongoDB stergerea unui document8. Php MongoDB stergerea unui document
8. Php MongoDB stergerea unui documentRazvan Raducanu, PhD
 
Object oriented mysqli connection function
Object oriented mysqli connection functionObject oriented mysqli connection function
Object oriented mysqli connection functionclickon2010
 

La actualidad más candente (20)

PHP Lecture 4 - Working with form, GET and Post Methods
PHP Lecture 4 - Working with form, GET and Post MethodsPHP Lecture 4 - Working with form, GET and Post Methods
PHP Lecture 4 - Working with form, GET and Post Methods
 
First step of Performance Tuning
First step of Performance TuningFirst step of Performance Tuning
First step of Performance Tuning
 
Php
PhpPhp
Php
 
PHP Lecture 6 - Php file uploading
PHP Lecture 6 - Php file uploadingPHP Lecture 6 - Php file uploading
PHP Lecture 6 - Php file uploading
 
Dependency Injection
Dependency InjectionDependency Injection
Dependency Injection
 
[Php] navigations
[Php] navigations[Php] navigations
[Php] navigations
 
[Php] navigations
[Php] navigations[Php] navigations
[Php] navigations
 
ETL for Pros: Getting Data Into MongoDB
ETL for Pros: Getting Data Into MongoDBETL for Pros: Getting Data Into MongoDB
ETL for Pros: Getting Data Into MongoDB
 
introduction to Django in five slides
introduction to Django in five slides introduction to Django in five slides
introduction to Django in five slides
 
MongoDB a document store that won't let you down.
MongoDB a document store that won't let you down.MongoDB a document store that won't let you down.
MongoDB a document store that won't let you down.
 
"Powerful Analysis with the Aggregation Pipeline (Tutorial)"
"Powerful Analysis with the Aggregation Pipeline (Tutorial)""Powerful Analysis with the Aggregation Pipeline (Tutorial)"
"Powerful Analysis with the Aggregation Pipeline (Tutorial)"
 
Php 2
Php 2Php 2
Php 2
 
Path::Tiny
Path::TinyPath::Tiny
Path::Tiny
 
MongoDB World 2019: Aggregation Pipeline Power++: How MongoDB 4.2 Pipeline Em...
MongoDB World 2019: Aggregation Pipeline Power++: How MongoDB 4.2 Pipeline Em...MongoDB World 2019: Aggregation Pipeline Power++: How MongoDB 4.2 Pipeline Em...
MongoDB World 2019: Aggregation Pipeline Power++: How MongoDB 4.2 Pipeline Em...
 
MongoDB .local Bengaluru 2019: Aggregation Pipeline Power++: How MongoDB 4.2 ...
MongoDB .local Bengaluru 2019: Aggregation Pipeline Power++: How MongoDB 4.2 ...MongoDB .local Bengaluru 2019: Aggregation Pipeline Power++: How MongoDB 4.2 ...
MongoDB .local Bengaluru 2019: Aggregation Pipeline Power++: How MongoDB 4.2 ...
 
MongoDBと位置情報 ~地理空間インデックスの紹介
MongoDBと位置情報 ~地理空間インデックスの紹介MongoDBと位置情報 ~地理空間インデックスの紹介
MongoDBと位置情報 ~地理空間インデックスの紹介
 
San Francisco Java User Group
San Francisco Java User GroupSan Francisco Java User Group
San Francisco Java User Group
 
Jina Bolton
Jina BoltonJina Bolton
Jina Bolton
 
8. Php MongoDB stergerea unui document
8. Php MongoDB stergerea unui document8. Php MongoDB stergerea unui document
8. Php MongoDB stergerea unui document
 
Object oriented mysqli connection function
Object oriented mysqli connection functionObject oriented mysqli connection function
Object oriented mysqli connection function
 

Destacado

Presentacio Mobile World Congress
Presentacio Mobile World CongressPresentacio Mobile World Congress
Presentacio Mobile World CongressCitilab Cornella
 
Leadership Turlock
Leadership TurlockLeadership Turlock
Leadership Turlockstancofair
 
Tabla Frecuencia De Medida De Arboles
Tabla Frecuencia De Medida De ArbolesTabla Frecuencia De Medida De Arboles
Tabla Frecuencia De Medida De ArbolesJorge Pineda
 
Our Library
Our LibraryOur Library
Our Librarybfant
 
Tabla Frecuencia De Medida De Arboles
Tabla Frecuencia De Medida De ArbolesTabla Frecuencia De Medida De Arboles
Tabla Frecuencia De Medida De ArbolesJorge Pineda
 
Python for Scientists
Python for ScientistsPython for Scientists
Python for ScientistsAndreas Dewes
 
Plucore way of using Catalyst
Plucore way of using CatalystPlucore way of using Catalyst
Plucore way of using CatalystDaisuke Komatsu
 
自社開発をしていなかった会社が Python を選んだ理由
自社開発をしていなかった会社が Python を選んだ理由自社開発をしていなかった会社が Python を選んだ理由
自社開発をしていなかった会社が Python を選んだ理由Daisuke Komatsu
 
Searching the Internet
Searching the Internet Searching the Internet
Searching the Internet guest32ae6
 
Corporate-Espionage
Corporate-EspionageCorporate-Espionage
Corporate-EspionageSam
 

Destacado (19)

Presentacio Mobile World Congress
Presentacio Mobile World CongressPresentacio Mobile World Congress
Presentacio Mobile World Congress
 
Els bolets
Els boletsEls bolets
Els bolets
 
Leadership Turlock
Leadership TurlockLeadership Turlock
Leadership Turlock
 
Attitude is everything
Attitude is everythingAttitude is everything
Attitude is everything
 
Living%20 Labs E Almirall
Living%20 Labs E AlmirallLiving%20 Labs E Almirall
Living%20 Labs E Almirall
 
Tabla Frecuencia De Medida De Arboles
Tabla Frecuencia De Medida De ArbolesTabla Frecuencia De Medida De Arboles
Tabla Frecuencia De Medida De Arboles
 
Our Library
Our LibraryOur Library
Our Library
 
lady gaga
lady gagalady gaga
lady gaga
 
Tabla Frecuencia De Medida De Arboles
Tabla Frecuencia De Medida De ArbolesTabla Frecuencia De Medida De Arboles
Tabla Frecuencia De Medida De Arboles
 
Szczecin
SzczecinSzczecin
Szczecin
 
Titi Escalante
Titi EscalanteTiti Escalante
Titi Escalante
 
Python for Scientists
Python for ScientistsPython for Scientists
Python for Scientists
 
Viatge final 4t
Viatge final 4tViatge final 4t
Viatge final 4t
 
Plucore way of using Catalyst
Plucore way of using CatalystPlucore way of using Catalyst
Plucore way of using Catalyst
 
Attitude is everything
Attitude is everythingAttitude is everything
Attitude is everything
 
自社開発をしていなかった会社が Python を選んだ理由
自社開発をしていなかった会社が Python を選んだ理由自社開発をしていなかった会社が Python を選んだ理由
自社開発をしていなかった会社が Python を選んだ理由
 
Searching the Internet
Searching the Internet Searching the Internet
Searching the Internet
 
HR
HRHR
HR
 
Corporate-Espionage
Corporate-EspionageCorporate-Espionage
Corporate-Espionage
 

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

Data::FormValidator Simplified
Data::FormValidator SimplifiedData::FormValidator Simplified
Data::FormValidator SimplifiedFred Moyer
 
20 modules i haven't yet talked about
20 modules i haven't yet talked about20 modules i haven't yet talked about
20 modules i haven't yet talked aboutTatsuhiko Miyagawa
 
Adventures in Optimization
Adventures in OptimizationAdventures in Optimization
Adventures in OptimizationDavid Golden
 
Designing Opeation Oriented Web Applications / YAPC::Asia Tokyo 2011
Designing Opeation Oriented Web Applications / YAPC::Asia Tokyo 2011Designing Opeation Oriented Web Applications / YAPC::Asia Tokyo 2011
Designing Opeation Oriented Web Applications / YAPC::Asia Tokyo 2011Masahiro Nagano
 
Bag Of Tricks From Iusethis
Bag Of Tricks From IusethisBag Of Tricks From Iusethis
Bag Of Tricks From IusethisMarcus Ramberg
 
The Zen of Lithium
The Zen of LithiumThe Zen of Lithium
The Zen of LithiumNate Abele
 
Forms in AngularJS
Forms in AngularJSForms in AngularJS
Forms in AngularJSEyal Vardi
 
Why Hacking WordPress Search Isn't Some Big Scary Thing
Why Hacking WordPress Search Isn't Some Big Scary ThingWhy Hacking WordPress Search Isn't Some Big Scary Thing
Why Hacking WordPress Search Isn't Some Big Scary ThingChris Reynolds
 
C A S Sample Php
C A S Sample PhpC A S Sample Php
C A S Sample PhpJH Lee
 
Introduction to CloudForecast / YAPC::Asia 2010 Tokyo
Introduction to CloudForecast / YAPC::Asia 2010 TokyoIntroduction to CloudForecast / YAPC::Asia 2010 Tokyo
Introduction to CloudForecast / YAPC::Asia 2010 TokyoMasahiro Nagano
 
Php code for online quiz
Php code for online quizPhp code for online quiz
Php code for online quizhnyb1002
 
Good Evils In Perl (Yapc Asia)
Good Evils In Perl (Yapc Asia)Good Evils In Perl (Yapc Asia)
Good Evils In Perl (Yapc Asia)Kang-min Liu
 
全裸でワンライナー(仮)
全裸でワンライナー(仮)全裸でワンライナー(仮)
全裸でワンライナー(仮)Yoshihiro Sugi
 
究極のコントローラを目指す
究極のコントローラを目指す究極のコントローラを目指す
究極のコントローラを目指すYasuo Harada
 

Similar a FormValidator::LazyWay で検証ルールをまとめよう (20)

Data::FormValidator Simplified
Data::FormValidator SimplifiedData::FormValidator Simplified
Data::FormValidator Simplified
 
Daily notes
Daily notesDaily notes
Daily notes
 
20 modules i haven't yet talked about
20 modules i haven't yet talked about20 modules i haven't yet talked about
20 modules i haven't yet talked about
 
Adventures in Optimization
Adventures in OptimizationAdventures in Optimization
Adventures in Optimization
 
Designing Opeation Oriented Web Applications / YAPC::Asia Tokyo 2011
Designing Opeation Oriented Web Applications / YAPC::Asia Tokyo 2011Designing Opeation Oriented Web Applications / YAPC::Asia Tokyo 2011
Designing Opeation Oriented Web Applications / YAPC::Asia Tokyo 2011
 
Bag Of Tricks From Iusethis
Bag Of Tricks From IusethisBag Of Tricks From Iusethis
Bag Of Tricks From Iusethis
 
SOLID in Practice
SOLID in PracticeSOLID in Practice
SOLID in Practice
 
The Zen of Lithium
The Zen of LithiumThe Zen of Lithium
The Zen of Lithium
 
Solid in practice
Solid in practiceSolid in practice
Solid in practice
 
Php functions
Php functionsPhp functions
Php functions
 
Forms in AngularJS
Forms in AngularJSForms in AngularJS
Forms in AngularJS
 
Why Hacking WordPress Search Isn't Some Big Scary Thing
Why Hacking WordPress Search Isn't Some Big Scary ThingWhy Hacking WordPress Search Isn't Some Big Scary Thing
Why Hacking WordPress Search Isn't Some Big Scary Thing
 
C A S Sample Php
C A S Sample PhpC A S Sample Php
C A S Sample Php
 
Perl6 in-production
Perl6 in-productionPerl6 in-production
Perl6 in-production
 
Introduction to CloudForecast / YAPC::Asia 2010 Tokyo
Introduction to CloudForecast / YAPC::Asia 2010 TokyoIntroduction to CloudForecast / YAPC::Asia 2010 Tokyo
Introduction to CloudForecast / YAPC::Asia 2010 Tokyo
 
Php code for online quiz
Php code for online quizPhp code for online quiz
Php code for online quiz
 
Good Evils In Perl (Yapc Asia)
Good Evils In Perl (Yapc Asia)Good Evils In Perl (Yapc Asia)
Good Evils In Perl (Yapc Asia)
 
全裸でワンライナー(仮)
全裸でワンライナー(仮)全裸でワンライナー(仮)
全裸でワンライナー(仮)
 
究極のコントローラを目指す
究極のコントローラを目指す究極のコントローラを目指す
究極のコントローラを目指す
 
Php.docx
Php.docxPhp.docx
Php.docx
 

Último

How AI, OpenAI, and ChatGPT impact business and software.
How AI, OpenAI, and ChatGPT impact business and software.How AI, OpenAI, and ChatGPT impact business and software.
How AI, OpenAI, and ChatGPT impact business and software.Curtis Poe
 
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks..."LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...Fwdays
 
DevoxxFR 2024 Reproducible Builds with Apache Maven
DevoxxFR 2024 Reproducible Builds with Apache MavenDevoxxFR 2024 Reproducible Builds with Apache Maven
DevoxxFR 2024 Reproducible Builds with Apache MavenHervé Boutemy
 
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)Mark Simos
 
Scanning the Internet for External Cloud Exposures via SSL Certs
Scanning the Internet for External Cloud Exposures via SSL CertsScanning the Internet for External Cloud Exposures via SSL Certs
Scanning the Internet for External Cloud Exposures via SSL CertsRizwan Syed
 
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek SchlawackFwdays
 
Gen AI in Business - Global Trends Report 2024.pdf
Gen AI in Business - Global Trends Report 2024.pdfGen AI in Business - Global Trends Report 2024.pdf
Gen AI in Business - Global Trends Report 2024.pdfAddepto
 
Unraveling Multimodality with Large Language Models.pdf
Unraveling Multimodality with Large Language Models.pdfUnraveling Multimodality with Large Language Models.pdf
Unraveling Multimodality with Large Language Models.pdfAlex Barbosa Coqueiro
 
Leverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage Cost
Leverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage CostLeverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage Cost
Leverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage CostZilliz
 
Advanced Test Driven-Development @ php[tek] 2024
Advanced Test Driven-Development @ php[tek] 2024Advanced Test Driven-Development @ php[tek] 2024
Advanced Test Driven-Development @ php[tek] 2024Scott Keck-Warren
 
Unleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding ClubUnleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding ClubKalema Edgar
 
Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!Commit University
 
H2O.ai CEO/Founder: Sri Ambati Keynote at Wells Fargo Day
H2O.ai CEO/Founder: Sri Ambati Keynote at Wells Fargo DayH2O.ai CEO/Founder: Sri Ambati Keynote at Wells Fargo Day
H2O.ai CEO/Founder: Sri Ambati Keynote at Wells Fargo DaySri Ambati
 
What's New in Teams Calling, Meetings and Devices March 2024
What's New in Teams Calling, Meetings and Devices March 2024What's New in Teams Calling, Meetings and Devices March 2024
What's New in Teams Calling, Meetings and Devices March 2024Stephanie Beckett
 
TeamStation AI System Report LATAM IT Salaries 2024
TeamStation AI System Report LATAM IT Salaries 2024TeamStation AI System Report LATAM IT Salaries 2024
TeamStation AI System Report LATAM IT Salaries 2024Lonnie McRorey
 
Streamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project SetupStreamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project SetupFlorian Wilhelm
 
Story boards and shot lists for my a level piece
Story boards and shot lists for my a level pieceStory boards and shot lists for my a level piece
Story boards and shot lists for my a level piececharlottematthew16
 
"ML in Production",Oleksandr Bagan
"ML in Production",Oleksandr Bagan"ML in Production",Oleksandr Bagan
"ML in Production",Oleksandr BaganFwdays
 
Artificial intelligence in cctv survelliance.pptx
Artificial intelligence in cctv survelliance.pptxArtificial intelligence in cctv survelliance.pptx
Artificial intelligence in cctv survelliance.pptxhariprasad279825
 

Último (20)

How AI, OpenAI, and ChatGPT impact business and software.
How AI, OpenAI, and ChatGPT impact business and software.How AI, OpenAI, and ChatGPT impact business and software.
How AI, OpenAI, and ChatGPT impact business and software.
 
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks..."LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
 
DevoxxFR 2024 Reproducible Builds with Apache Maven
DevoxxFR 2024 Reproducible Builds with Apache MavenDevoxxFR 2024 Reproducible Builds with Apache Maven
DevoxxFR 2024 Reproducible Builds with Apache Maven
 
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
 
Scanning the Internet for External Cloud Exposures via SSL Certs
Scanning the Internet for External Cloud Exposures via SSL CertsScanning the Internet for External Cloud Exposures via SSL Certs
Scanning the Internet for External Cloud Exposures via SSL Certs
 
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
 
Gen AI in Business - Global Trends Report 2024.pdf
Gen AI in Business - Global Trends Report 2024.pdfGen AI in Business - Global Trends Report 2024.pdf
Gen AI in Business - Global Trends Report 2024.pdf
 
Unraveling Multimodality with Large Language Models.pdf
Unraveling Multimodality with Large Language Models.pdfUnraveling Multimodality with Large Language Models.pdf
Unraveling Multimodality with Large Language Models.pdf
 
Leverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage Cost
Leverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage CostLeverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage Cost
Leverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage Cost
 
Advanced Test Driven-Development @ php[tek] 2024
Advanced Test Driven-Development @ php[tek] 2024Advanced Test Driven-Development @ php[tek] 2024
Advanced Test Driven-Development @ php[tek] 2024
 
Unleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding ClubUnleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding Club
 
E-Vehicle_Hacking_by_Parul Sharma_null_owasp.pptx
E-Vehicle_Hacking_by_Parul Sharma_null_owasp.pptxE-Vehicle_Hacking_by_Parul Sharma_null_owasp.pptx
E-Vehicle_Hacking_by_Parul Sharma_null_owasp.pptx
 
Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!
 
H2O.ai CEO/Founder: Sri Ambati Keynote at Wells Fargo Day
H2O.ai CEO/Founder: Sri Ambati Keynote at Wells Fargo DayH2O.ai CEO/Founder: Sri Ambati Keynote at Wells Fargo Day
H2O.ai CEO/Founder: Sri Ambati Keynote at Wells Fargo Day
 
What's New in Teams Calling, Meetings and Devices March 2024
What's New in Teams Calling, Meetings and Devices March 2024What's New in Teams Calling, Meetings and Devices March 2024
What's New in Teams Calling, Meetings and Devices March 2024
 
TeamStation AI System Report LATAM IT Salaries 2024
TeamStation AI System Report LATAM IT Salaries 2024TeamStation AI System Report LATAM IT Salaries 2024
TeamStation AI System Report LATAM IT Salaries 2024
 
Streamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project SetupStreamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project Setup
 
Story boards and shot lists for my a level piece
Story boards and shot lists for my a level pieceStory boards and shot lists for my a level piece
Story boards and shot lists for my a level piece
 
"ML in Production",Oleksandr Bagan
"ML in Production",Oleksandr Bagan"ML in Production",Oleksandr Bagan
"ML in Production",Oleksandr Bagan
 
Artificial intelligence in cctv survelliance.pptx
Artificial intelligence in cctv survelliance.pptxArtificial intelligence in cctv survelliance.pptx
Artificial intelligence in cctv survelliance.pptx
 

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

  • 1.
  • 2.
  • 3.
  • 4.
  • 5.
  • 6.
  • 7.
  • 8.
  • 9.
  • 10.
  • 11.
  • 12.
  • 13.
  • 14.
  • 15.
  • 16.
  • 17.
  • 18.
  • 19.
  • 20.
  • 21.
  • 22.
  • 23.
  • 24.
  • 25. 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 => ' ' } }, };
  • 26. use FormValidator::LazyWay; my $fv = FormValidator::LazyWay->new($config); my $result = $fv->check($q, { required => [qw/nickname email password/], optional => [qw/message/] });
  • 27. my $result = $fv->check($q, { required => [qw/title/], optional => [qw/body/] }); my $result = $fv->check($q, { optional => [qw/title body/] });
  • 28. 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; }
  • 29. setting: my $result = $fv->check( $cgi, strict: { required => [qw/email/], email: level => { email => 'loose' rule: } - Email#email } loose: ); email: rule: - Email#email_loose
  • 30. setting: regexp_map: '_id$': rule: - Number#integer
  • 31. merge: date: format: "%04d-%02d-%02d" fields: - year - month - day strict: date: rule: - DateTime#date
  • 32.
  • 33.
  • 34. setting: strict: date: filter: - Unify#hyphen rule: - DateTime#date fix: - DateTime#format: - '%Y-%m-%d'
  • 35. 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};
  • 36. 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; }
  • 37. 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, });
  • 38.
  • 39.
  • 40.
  • 41.
  • 42.
  • 43.
  • 44. messages : ja : rule_message : __field__ __rule__ rule : Email#email : String#length : $_[min] $_[max]
  • 45. messages : ja : rule_message : __field__ __rule__ rule : Email#email : String#length : $_[min] $_[max]