Ch13: Model Validation Flashcards
Define validation
Process of checking data conforms to criteria to insure only meaningful data is stored
Client-side or Server-side: Validation occurring in browser using JavaScript or HTML
Client-side Validation
Client-side or Server-side: Validation occurring on web server, utilizing Java
Server-side Validation
The ____ is responsible for defining validation rules, while the ____ is responsible for checking validation rules when data is submitted to the server
Model, controller
Why should you validate all data submitted by users?
- Data remains well structured
- Avoid unexpected errors
Is both client-side and server-side validation required?
Yes, client-side validation can be bypassed
Use of javax.validation.constraints package?
Provides annotations useful for validating model fields
Annotation that specifies minimum and/or maximum length for a string.
@Size
Annotation that specifies the minimum value of a numeric field
@Min
Annotation that specifies the max value of a numeric field
@Max
Annotation that specifies that a string field should conform to email formatting standards.
Annotation that specifies that a field may not be null.
@NotNull
Annotation that specifies that a string field contains at least one non-whitespace character.
@NotBlank