Part II. Constraint Validation

For catching various cases of flawed data, we need to define suitable integrity constraints that can be used by the application's data validation mechanisms. Integrity constraints may take many different forms. The most important type of integrity constraints are property constraints, which define conditions on the admissible property values of an object.

Table of Contents

7. Constraint Validation
1. Introduction
2. Integrity Constraints
2.1. String Length Constraints
2.2. Mandatory Value Constraints
2.3. Range Constraints
2.4. Interval Constraints
2.5. Pattern Constraints
2.6. Cardinality Constraints
2.7. Uniqueness Constraints
2.8. Standard Identifiers (Primary Keys)
2.9. Referential Integrity Constraints
2.10. Frozen and Read-Only Value Constraints
2.11. Beyond property constraints
3. Responsive Validation
4. Constraint Validation in MVC Applications
5. Adding Constraints to a Design Model
6. Summary
7. Criteria for Evaluating the Validation Support of Frameworks
8. Quiz Questions
8.1. Question 1: Where to check constraints
8.2. Question 2: Where to define constraints
8.3. Question 3: Counting constraints
8.4. Question 4: Constraint names
8.5. Question 5: Compliant objects
8. Constraint Validation in Plain JS
1. Introduction
2. New Issues
3. Make a JavaScript Class Model
4. Set up the Folder Structure Adding Some Library Files
4.1. Provide general utility functions and JavaScript fixes in library files
4.2. Create a start page
5. Write the Model Code
5.1. Summary
5.2. Code the model class as a constructor function
5.3. Code the property checks
5.4. Code the property setters
5.5. Add a serialization function
5.6. Data management operations
6. Write the View Code
6.1. The data management UI pages
6.2. Initialize the app
6.3. Set up the user interface
7. Run the App and Get the Code
8. Possible Variations and Extensions
8.1. Adding an object-level validation function
8.2. Using implicit JS setters
9. Points of Attention
9.1. Boilerplate code
9.2. Configuring the UI for preventing invalid user input
10. Practice Projects
10.1. Project 1 - Validate movie data
10.2. Project 2 - Validate country data
11. Quiz Questions
11.1. Question 1: Validation in setter (1)
11.2. Question 2: Validation in setter (2)
11.3. Question 3: Methods to add in JS class model
11.4. Question 4: Implementing constraints
9. Constraint Validation in Java EE
1. Java Annotations for Persistent Data Management and Constraint Validation
1.1. JPA constraint annotations
1.2. Bean Validation annotations
2. New Issues
3. Make an Entity Class Model
4. Write the Model Code
4.1. Type mapping
4.2. Code the constraints as annotations
4.3. Checking uniqueness constraints
4.4. Dealing with model-related exceptions
4.5. Requiring non-empty strings
5. Write the View Code
5.1. Validation in the Create use case
5.2. Validation in the Update use case
6. Defining a Custom Validation Annotation
7. Run the App and Get the Code
8. Possible Variations and Extensions
8.1. Object-level constraint validation
8.2. JSF custom validators
9. Practice Projects
9.1. Project 1 - Validate movie data
9.2. Project 2 - Validate country data
10. Quiz Questions
10.1. Question 1: String length validation
10.2. Question 2: Requiring a value
10.3. Question 3: Defining a custom validation annotation
10.4. Question 4: JSF custom validator method
10.5. Question 5: Show validation error messages with JSF