Part II. Integrity Constraints

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

4. 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. Quiz Questions
7.1. Question 1: Where to check constraints
7.2. Question 2: Where to define constraints
7.3. Question 3: Counting constraints
7.4. Question 4: Constraint names
7.5. Question 5: Compliant objects
5. Constraint Validation in Plain JS
1. Introduction
2. New Issues
3. Using ES6 Modules
4. Make a JavaScript Class Model
5. Set up the Folder Structure
5.1. Provide utility functions and error classes in library files
5.2. Create a start page
6. Write the Model Code
6.1. Summary
6.2. Code the model class as a constructor function
6.3. Code the property checks
6.4. Code the property setters
6.5. Add a serialization function
6.6. Data management operations
7. Write the View Code
7.1. Set up the user interface for Create Book
7.2. Set up the user interface for Update Book
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
9.3. Improving the user experience by showing helpful auto-complete suggestions
10. Quiz Questions
10.1. Question 1: Methods to add in JS class model
10.2. Question 2: Implementing constraints
10.3. Question 3: Implementing setter methods
11. Practice Projects
11.1. Project 1 - Validate movie data
11.2. Project 2 - Validate country data