Challenge: Model Validations

Work through a challenge to test your understanding of validations.

We'll cover the following

Problem statement

In this challenge, you have to make changes to the model code of your application to do the following:

  1. Add a check function that validates the constraints defined for the property, and a setter method that invokes the check function and will be used for setting the value of the property.

  2. Perform validation before any data is saved in the add and update methods.

You’ll be using the Movie App introduced in the previous challenge. You can make the assumption that all the data can be kept in the main memory. Persistent data storage is implemented with JavaScript’s Local Storage API.

The application deals with just one object type, Movie, as depicted in the following class diagram:

Get hands-on with 1200+ tech skills courses.