10. Exploring the validation framework Flashcards

1
Q

What is the architecture of the Validation Framework? Think the 3 layers and how they fit together…

A

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.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

Think about when/why you’d want to use: built-in validators, custom validators, implemention your own validate() on your action.

A

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.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

What’s an expression validator useful for?

A

Using OGNL to write a validation.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

What interfaces are provided for our Custom Validator if we chose to implement one? What’s the difference between them?

A

ValidatorSupport – Validating the whole action

FieldValidatorSupport – Validating a given field.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

What is short-circuit validations? How do you configure it, what’s the benefit?

A

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.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly