10. Exploring the validation framework Flashcards
What is the architecture of the Validation Framework? Think the 3 layers and how they fit together…
Domain Data – Your action has properties that need to be validated.
Validation Meta-Data – Through annotation or ClassName-validator.xml you define which properties need to be validated against which validator.
Validators – Implementations that check the property.
Think about when/why you’d want to use: built-in validators, custom validators, implemention your own validate() on your action.
built-in validators – Use whenever you can, less code to deal with.
custom validators – If you will re-use this logic in multiple actions, create a re-usable custom validator for it!
validate() – You can’t use a built-in, and it’s a one off then just throw it in the action.
What’s an expression validator useful for?
Using OGNL to write a validation.
What interfaces are provided for our Custom Validator if we chose to implement one? What’s the difference between them?
ValidatorSupport – Validating the whole action
FieldValidatorSupport – Validating a given field.
What is short-circuit validations? How do you configure it, what’s the benefit?
If a validator fail, have it fail right away rather than continuing to check.
Configure it by adding the attribute short-circuit=”true” to a validator.
Benefit is in this example the expensive passwordintegrity check doesn’t run if password isn’t correct length.