SlideShare una empresa de Scribd logo
1 de 52
My Journey to Validate Muhammad Saqib Sarwar [email_address]
1.To share my experience(thought process) of  choosing a Validator framework. 2.To deliver basic knowledge of my chosen tool. Basic Goals Muhammad Saqib Sarwar  [email_address]
[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],How I felt the need ? Simply Means a huge collection of if-else statements Muhammad Saqib Sarwar  [email_address]
[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],How I felt the need ? Muhammad Saqib Sarwar  [email_address]
[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],What I did next …  Muhammad Saqib Sarwar  [email_address]
[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],Which one to use ..? Muhammad Saqib Sarwar  [email_address]
[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],Validation in Spring 2.0.8 Muhammad Saqib Sarwar  [email_address]
[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],Commons Validator Muhammad Saqib Sarwar  [email_address]
[object Object],[object Object],[object Object],[object Object],[object Object],Commons Validator Muhammad Saqib Sarwar  [email_address]
[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],Muhammad Saqib Sarwar  [email_address]
[object Object],[object Object],[object Object],[object Object],Steps to use JaValid  Muhammad Saqib Sarwar  [email_address]
[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],Few disadvantages of JaValid ! Good Solution but not as simple and easy as hibernate validator Muhammad Saqib Sarwar  [email_address]
[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],Hibernate Validator Muhammad Saqib Sarwar  [email_address]
[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],Hibernate Validator ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],Muhammad Saqib Sarwar  [email_address]
[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],Hibernate Validator Muhammad Saqib Sarwar  [email_address]
Sample Code [Annotated Account Bean] /*--------- Simple Bean ---------------*/ public class Account  { @NotEmpty @Length(min=10,max=100) private String accountTitle; @NotEmpty private String processingCode; // regular getters and setters methods } Hibernate Validator Muhammad Saqib Sarwar  [email_address]
Validation Code: Account account = new   Account(); account.setAccountTitle(&quot;Mobex Ltd&quot;); ClassValidator<Account> accountValidator = new   ClassValidator<Account>(Account.class); InvalidValue[] validationMessages = accountValidator. getInvalidValues (account); for(InvalidValue msg:validationMessages) System.out.println(msg.getPropertyPath()+&quot;-&quot;+msg.getMessage()); OUTPUT accountTitle-length must be between 10 and 100 processingCode-may not be null or empty Hibernate Validator Muhammad Saqib Sarwar  [email_address]
public class Account  { @NotEmpty @Length(min=10,max=100) private String accountTitle; @NotEmpty private String processingCode; // regular getters and setters methods } Hibernate Validator Muhammad Saqib Sarwar  [email_address]
public class Account  { @NotEmpty @Length(min=10,max=100) private String accountTitle; @NotEmpty @ProcessingCode(code=IProcessingCode.  CHECK_BALANCE) private String processingCode; // regular getters and setters methods } Hibernate Validator Muhammad Saqib Sarwar  [email_address]
[object Object],[object Object],[object Object],Hibernate Validator Muhammad Saqib Sarwar  [email_address]
[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],Hibernate Validator org.hibernate.validator.ValidatorClass Muhammad Saqib Sarwar  [email_address]
2. Constraint Validator Implementation Class public class ProcessingCodeValidator implements  Serializable,  Validator<ProcessingCode>  { private static final long  serialVersionUID = 1146464976464879846L; private String code; public void  initialize (ProcessingCode parameter) { code = parameter.code(); } public boolean  isValid (Object value) { if ( value == null )return false; if (!( value instanceof String)) return false; String str = (String) value; if(str.equals(code)) return true; return false; } } Muhammad Saqib Sarwar  [email_address]
Account account = new Account(); account.setAccountTitle(&quot;Mobex Ltd&quot;); account.setProcessingCode(IProcessingCode. CREDIT_ACCOUNT); ClassValidator<Account> accountValidator = new  ClassValidator<Account>(Account.class); InvalidValue[] validationMessages = accountValidator.getInvalidValues(account); for(InvalidValue msg:validationMessages) System. out.println(msg.getPropertyPath()+&quot;-&quot;+msg.getMessage()); OUTPUT accountTitle-length must be between 10 and 100 processingCode-Invalid Processing Code Hibernate Validator Muhammad Saqib Sarwar  [email_address]
[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],Hibernate Validator Muhammad Saqib Sarwar  [email_address]
[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],Muhammad Saqib Sarwar  [email_address]
[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],Summary Muhammad Saqib Sarwar  [email_address]
My journey to use a validation framework
My journey to use a validation framework
My journey to use a validation framework
My journey to use a validation framework
My journey to use a validation framework
My journey to use a validation framework
My journey to use a validation framework
My journey to use a validation framework
My journey to use a validation framework
My journey to use a validation framework
My journey to use a validation framework
My journey to use a validation framework
My journey to use a validation framework
My journey to use a validation framework
My journey to use a validation framework
My journey to use a validation framework
My journey to use a validation framework
My journey to use a validation framework
My journey to use a validation framework
My journey to use a validation framework
My journey to use a validation framework
My journey to use a validation framework
My journey to use a validation framework
My journey to use a validation framework
My journey to use a validation framework
My journey to use a validation framework

Más contenido relacionado

La actualidad más candente

Typed? Dynamic? Both! Cross-platform DSLs in C#
Typed? Dynamic? Both! Cross-platform DSLs in C#Typed? Dynamic? Both! Cross-platform DSLs in C#
Typed? Dynamic? Both! Cross-platform DSLs in C#Vagif Abilov
 
oracle soa Examples
oracle soa Examplesoracle soa Examples
oracle soa Examplesxavier john
 
Secure Dot Net Programming
Secure Dot Net ProgrammingSecure Dot Net Programming
Secure Dot Net ProgrammingAdam Getchell
 
Java Security And Authentacation
Java Security And AuthentacationJava Security And Authentacation
Java Security And Authentacationckofoed
 
Dependency injection with unity 2.0 Dmytro Mindra Lohika
Dependency injection with unity 2.0 Dmytro Mindra LohikaDependency injection with unity 2.0 Dmytro Mindra Lohika
Dependency injection with unity 2.0 Dmytro Mindra LohikaAlex Tumanoff
 
Java Svet - Communication Between Android App Components
Java Svet - Communication Between Android App ComponentsJava Svet - Communication Between Android App Components
Java Svet - Communication Between Android App ComponentsAleksandar Ilić
 
Rails Best Practices
Rails Best PracticesRails Best Practices
Rails Best PracticesIcalia Labs
 
Java Web Programming [9/9] : Web Application Security
Java Web Programming [9/9] : Web Application SecurityJava Web Programming [9/9] : Web Application Security
Java Web Programming [9/9] : Web Application SecurityIMC Institute
 
SPCA2013 - Test-driven Development with SharePoint 2013 and Visual Studio
SPCA2013 - Test-driven Development with SharePoint 2013 and Visual StudioSPCA2013 - Test-driven Development with SharePoint 2013 and Visual Studio
SPCA2013 - Test-driven Development with SharePoint 2013 and Visual StudioNCCOMMS
 
Selenium training
Selenium trainingSelenium training
Selenium trainingRobin0590
 
Justmeans power point
Justmeans power pointJustmeans power point
Justmeans power pointjustmeanscsr
 

La actualidad más candente (19)

Typed? Dynamic? Both! Cross-platform DSLs in C#
Typed? Dynamic? Both! Cross-platform DSLs in C#Typed? Dynamic? Both! Cross-platform DSLs in C#
Typed? Dynamic? Both! Cross-platform DSLs in C#
 
oracle soa Examples
oracle soa Examplesoracle soa Examples
oracle soa Examples
 
Secure Dot Net Programming
Secure Dot Net ProgrammingSecure Dot Net Programming
Secure Dot Net Programming
 
TY.BSc.IT Java QB U4
TY.BSc.IT Java QB U4TY.BSc.IT Java QB U4
TY.BSc.IT Java QB U4
 
TY.BSc.IT Java QB U3
TY.BSc.IT Java QB U3TY.BSc.IT Java QB U3
TY.BSc.IT Java QB U3
 
Rails Best Practices
Rails Best PracticesRails Best Practices
Rails Best Practices
 
Java Security And Authentacation
Java Security And AuthentacationJava Security And Authentacation
Java Security And Authentacation
 
Dependency injection with unity 2.0 Dmytro Mindra Lohika
Dependency injection with unity 2.0 Dmytro Mindra LohikaDependency injection with unity 2.0 Dmytro Mindra Lohika
Dependency injection with unity 2.0 Dmytro Mindra Lohika
 
CDI @javaonehyderabad
CDI @javaonehyderabadCDI @javaonehyderabad
CDI @javaonehyderabad
 
Java Svet - Communication Between Android App Components
Java Svet - Communication Between Android App ComponentsJava Svet - Communication Between Android App Components
Java Svet - Communication Between Android App Components
 
Wheels
WheelsWheels
Wheels
 
Rails Best Practices
Rails Best PracticesRails Best Practices
Rails Best Practices
 
Java Web Programming [9/9] : Web Application Security
Java Web Programming [9/9] : Web Application SecurityJava Web Programming [9/9] : Web Application Security
Java Web Programming [9/9] : Web Application Security
 
SPCA2013 - Test-driven Development with SharePoint 2013 and Visual Studio
SPCA2013 - Test-driven Development with SharePoint 2013 and Visual StudioSPCA2013 - Test-driven Development with SharePoint 2013 and Visual Studio
SPCA2013 - Test-driven Development with SharePoint 2013 and Visual Studio
 
Selenium training
Selenium trainingSelenium training
Selenium training
 
Javascript
JavascriptJavascript
Javascript
 
J2EE-assignment
 J2EE-assignment J2EE-assignment
J2EE-assignment
 
Justmeans power point
Justmeans power pointJustmeans power point
Justmeans power point
 
Javascript
JavascriptJavascript
Javascript
 

Destacado

JSRs 303 and 330 in Action
JSRs 303 and 330 in ActionJSRs 303 and 330 in Action
JSRs 303 and 330 in Actionsimonetripodi
 
Declarative input validation with JSR 303 and ExtVal
Declarative input validation with JSR 303 and ExtVal Declarative input validation with JSR 303 and ExtVal
Declarative input validation with JSR 303 and ExtVal Bart Kummel
 
Declarative Input Validation with JSR 303 and ExtVal
Declarative Input Validation with JSR 303 and ExtValDeclarative Input Validation with JSR 303 and ExtVal
Declarative Input Validation with JSR 303 and ExtValBart Kummel
 
computer system validation
computer system validationcomputer system validation
computer system validationGopal Patel
 
Computer System Validation
Computer System ValidationComputer System Validation
Computer System ValidationEric Silva
 

Destacado (7)

JSRs 303 and 330 in Action
JSRs 303 and 330 in ActionJSRs 303 and 330 in Action
JSRs 303 and 330 in Action
 
Declarative input validation with JSR 303 and ExtVal
Declarative input validation with JSR 303 and ExtVal Declarative input validation with JSR 303 and ExtVal
Declarative input validation with JSR 303 and ExtVal
 
Declarative Input Validation with JSR 303 and ExtVal
Declarative Input Validation with JSR 303 and ExtValDeclarative Input Validation with JSR 303 and ExtVal
Declarative Input Validation with JSR 303 and ExtVal
 
computer system validation
computer system validationcomputer system validation
computer system validation
 
Domain Driven Design 101
Domain Driven Design 101Domain Driven Design 101
Domain Driven Design 101
 
Computer System Validation
Computer System ValidationComputer System Validation
Computer System Validation
 
Jsr 303
Jsr 303Jsr 303
Jsr 303
 

Similar a My journey to use a validation framework

Code your Own: Authentication Provider for Blackboard Learn
Code your Own: Authentication Provider for Blackboard LearnCode your Own: Authentication Provider for Blackboard Learn
Code your Own: Authentication Provider for Blackboard LearnDan Rinzel
 
Apex Testing and Best Practices
Apex Testing and Best PracticesApex Testing and Best Practices
Apex Testing and Best PracticesJitendra Zaa
 
Test Automation Frameworks Final
Test Automation Frameworks   FinalTest Automation Frameworks   Final
Test Automation Frameworks FinalMargaret_Dickman
 
Jug Guice Presentation
Jug Guice PresentationJug Guice Presentation
Jug Guice PresentationDmitry Buzdin
 
Certified Core Java Developer
Certified Core Java DeveloperCertified Core Java Developer
Certified Core Java DeveloperNarender Rana
 
Core Java Certification
Core Java CertificationCore Java Certification
Core Java CertificationVskills
 
Lecture 12: React-Native Firebase Authentication
Lecture 12: React-Native Firebase AuthenticationLecture 12: React-Native Firebase Authentication
Lecture 12: React-Native Firebase AuthenticationKobkrit Viriyayudhakorn
 
Java EE 8 security and JSON binding API
Java EE 8 security and JSON binding APIJava EE 8 security and JSON binding API
Java EE 8 security and JSON binding APIAlex Theedom
 
TechDays 2013 Jari Kallonen: What's New WebForms 4.5
TechDays 2013 Jari Kallonen: What's New WebForms 4.5TechDays 2013 Jari Kallonen: What's New WebForms 4.5
TechDays 2013 Jari Kallonen: What's New WebForms 4.5Tieturi Oy
 
Test Automation Best Practices (with SOA test approach)
Test Automation Best Practices (with SOA test approach)Test Automation Best Practices (with SOA test approach)
Test Automation Best Practices (with SOA test approach)Leonard Fingerman
 
Lab Management with TFS 2010
Lab Management with TFS 2010Lab Management with TFS 2010
Lab Management with TFS 2010Ed Blankenship
 
EWD 3 Training Course Part 11: Handling Errors in QEWD
EWD 3 Training Course Part 11: Handling Errors in QEWDEWD 3 Training Course Part 11: Handling Errors in QEWD
EWD 3 Training Course Part 11: Handling Errors in QEWDRob Tweed
 
Unit test candidate solutions
Unit test candidate solutionsUnit test candidate solutions
Unit test candidate solutionsbenewu
 
Asp.net mvc training
Asp.net mvc trainingAsp.net mvc training
Asp.net mvc trainingicubesystem
 
Workshop quality assurance for php projects - phpdublin
Workshop quality assurance for php projects - phpdublinWorkshop quality assurance for php projects - phpdublin
Workshop quality assurance for php projects - phpdublinMichelangelo van Dam
 

Similar a My journey to use a validation framework (20)

Stored procedures
Stored proceduresStored procedures
Stored procedures
 
Code your Own: Authentication Provider for Blackboard Learn
Code your Own: Authentication Provider for Blackboard LearnCode your Own: Authentication Provider for Blackboard Learn
Code your Own: Authentication Provider for Blackboard Learn
 
Apex Testing and Best Practices
Apex Testing and Best PracticesApex Testing and Best Practices
Apex Testing and Best Practices
 
Test Automation Frameworks Final
Test Automation Frameworks   FinalTest Automation Frameworks   Final
Test Automation Frameworks Final
 
Asp.NET MVC
Asp.NET MVCAsp.NET MVC
Asp.NET MVC
 
Angular genericforms2
Angular genericforms2Angular genericforms2
Angular genericforms2
 
Jug Guice Presentation
Jug Guice PresentationJug Guice Presentation
Jug Guice Presentation
 
Certified Core Java Developer
Certified Core Java DeveloperCertified Core Java Developer
Certified Core Java Developer
 
Core Java Certification
Core Java CertificationCore Java Certification
Core Java Certification
 
Lecture 12: React-Native Firebase Authentication
Lecture 12: React-Native Firebase AuthenticationLecture 12: React-Native Firebase Authentication
Lecture 12: React-Native Firebase Authentication
 
Java EE 8 security and JSON binding API
Java EE 8 security and JSON binding APIJava EE 8 security and JSON binding API
Java EE 8 security and JSON binding API
 
TechDays 2013 Jari Kallonen: What's New WebForms 4.5
TechDays 2013 Jari Kallonen: What's New WebForms 4.5TechDays 2013 Jari Kallonen: What's New WebForms 4.5
TechDays 2013 Jari Kallonen: What's New WebForms 4.5
 
Test Automation Best Practices (with SOA test approach)
Test Automation Best Practices (with SOA test approach)Test Automation Best Practices (with SOA test approach)
Test Automation Best Practices (with SOA test approach)
 
Lab Management with TFS 2010
Lab Management with TFS 2010Lab Management with TFS 2010
Lab Management with TFS 2010
 
Clean tests good tests
Clean tests   good testsClean tests   good tests
Clean tests good tests
 
Apex Unit Testing in the Real World
Apex Unit Testing in the Real WorldApex Unit Testing in the Real World
Apex Unit Testing in the Real World
 
EWD 3 Training Course Part 11: Handling Errors in QEWD
EWD 3 Training Course Part 11: Handling Errors in QEWDEWD 3 Training Course Part 11: Handling Errors in QEWD
EWD 3 Training Course Part 11: Handling Errors in QEWD
 
Unit test candidate solutions
Unit test candidate solutionsUnit test candidate solutions
Unit test candidate solutions
 
Asp.net mvc training
Asp.net mvc trainingAsp.net mvc training
Asp.net mvc training
 
Workshop quality assurance for php projects - phpdublin
Workshop quality assurance for php projects - phpdublinWorkshop quality assurance for php projects - phpdublin
Workshop quality assurance for php projects - phpdublin
 

Último

Exploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone ProcessorsExploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone Processorsdebabhi2
 
GenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationGenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationMichael W. Hawkins
 
IAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsIAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsEnterprise Knowledge
 
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking MenDelhi Call girls
 
Handwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsHandwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsMaria Levchenko
 
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc
 
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...Neo4j
 
Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024The Digital Insurer
 
How to convert PDF to text with Nanonets
How to convert PDF to text with NanonetsHow to convert PDF to text with Nanonets
How to convert PDF to text with Nanonetsnaman860154
 
A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024Results
 
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...apidays
 
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptxHampshireHUG
 
Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024The Digital Insurer
 
Breaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountBreaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountPuma Security, LLC
 
Developing An App To Navigate The Roads of Brazil
Developing An App To Navigate The Roads of BrazilDeveloping An App To Navigate The Roads of Brazil
Developing An App To Navigate The Roads of BrazilV3cube
 
08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking MenDelhi Call girls
 
Top 5 Benefits OF Using Muvi Live Paywall For Live Streams
Top 5 Benefits OF Using Muvi Live Paywall For Live StreamsTop 5 Benefits OF Using Muvi Live Paywall For Live Streams
Top 5 Benefits OF Using Muvi Live Paywall For Live StreamsRoshan Dwivedi
 
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure serviceWhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure servicePooja Nehwal
 
Data Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonData Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonAnna Loughnan Colquhoun
 
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdfThe Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdfEnterprise Knowledge
 

Último (20)

Exploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone ProcessorsExploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone Processors
 
GenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationGenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day Presentation
 
IAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsIAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI Solutions
 
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
 
Handwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsHandwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed texts
 
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
 
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
 
Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024
 
How to convert PDF to text with Nanonets
How to convert PDF to text with NanonetsHow to convert PDF to text with Nanonets
How to convert PDF to text with Nanonets
 
A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024
 
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
 
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
 
Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024
 
Breaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountBreaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path Mount
 
Developing An App To Navigate The Roads of Brazil
Developing An App To Navigate The Roads of BrazilDeveloping An App To Navigate The Roads of Brazil
Developing An App To Navigate The Roads of Brazil
 
08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men
 
Top 5 Benefits OF Using Muvi Live Paywall For Live Streams
Top 5 Benefits OF Using Muvi Live Paywall For Live StreamsTop 5 Benefits OF Using Muvi Live Paywall For Live Streams
Top 5 Benefits OF Using Muvi Live Paywall For Live Streams
 
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure serviceWhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
 
Data Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonData Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt Robison
 
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdfThe Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
 

My journey to use a validation framework

  • 1. My Journey to Validate Muhammad Saqib Sarwar [email_address]
  • 2. 1.To share my experience(thought process) of choosing a Validator framework. 2.To deliver basic knowledge of my chosen tool. Basic Goals Muhammad Saqib Sarwar [email_address]
  • 3.
  • 4.
  • 5.
  • 6.
  • 7.
  • 8.
  • 9.
  • 10.
  • 11.
  • 12.
  • 13.
  • 14.
  • 15.
  • 16. Sample Code [Annotated Account Bean] /*--------- Simple Bean ---------------*/ public class Account { @NotEmpty @Length(min=10,max=100) private String accountTitle; @NotEmpty private String processingCode; // regular getters and setters methods } Hibernate Validator Muhammad Saqib Sarwar [email_address]
  • 17. Validation Code: Account account = new Account(); account.setAccountTitle(&quot;Mobex Ltd&quot;); ClassValidator<Account> accountValidator = new ClassValidator<Account>(Account.class); InvalidValue[] validationMessages = accountValidator. getInvalidValues (account); for(InvalidValue msg:validationMessages) System.out.println(msg.getPropertyPath()+&quot;-&quot;+msg.getMessage()); OUTPUT accountTitle-length must be between 10 and 100 processingCode-may not be null or empty Hibernate Validator Muhammad Saqib Sarwar [email_address]
  • 18. public class Account { @NotEmpty @Length(min=10,max=100) private String accountTitle; @NotEmpty private String processingCode; // regular getters and setters methods } Hibernate Validator Muhammad Saqib Sarwar [email_address]
  • 19. public class Account { @NotEmpty @Length(min=10,max=100) private String accountTitle; @NotEmpty @ProcessingCode(code=IProcessingCode. CHECK_BALANCE) private String processingCode; // regular getters and setters methods } Hibernate Validator Muhammad Saqib Sarwar [email_address]
  • 20.
  • 21.
  • 22. 2. Constraint Validator Implementation Class public class ProcessingCodeValidator implements Serializable, Validator<ProcessingCode> { private static final long serialVersionUID = 1146464976464879846L; private String code; public void initialize (ProcessingCode parameter) { code = parameter.code(); } public boolean isValid (Object value) { if ( value == null )return false; if (!( value instanceof String)) return false; String str = (String) value; if(str.equals(code)) return true; return false; } } Muhammad Saqib Sarwar [email_address]
  • 23. Account account = new Account(); account.setAccountTitle(&quot;Mobex Ltd&quot;); account.setProcessingCode(IProcessingCode. CREDIT_ACCOUNT); ClassValidator<Account> accountValidator = new ClassValidator<Account>(Account.class); InvalidValue[] validationMessages = accountValidator.getInvalidValues(account); for(InvalidValue msg:validationMessages) System. out.println(msg.getPropertyPath()+&quot;-&quot;+msg.getMessage()); OUTPUT accountTitle-length must be between 10 and 100 processingCode-Invalid Processing Code Hibernate Validator Muhammad Saqib Sarwar [email_address]
  • 24.
  • 25.
  • 26.