Exercise 09: Entity Validation - jkneal/spring-angular-train GitHub Wiki
Goals
Until now we have not done any validation on our objects before they are saved to the database. This is fine in some situations, but there are other cases where you have specific rules for the structure of the data in your system. During this exercise we will add some basic validations to the Store object.
Instructions
-
Review the new tests in the
StoreRepositoryTestclass -
Add the following validations to the
Storeclass:
- The name property should not be blank and should be between 5 and 40 characters in length
- The owner property should not be blank and should be between 1 and 40 characters in length
- The website property should not be blank and should be between 1 and 120 characters in length
- The open property should not be null
- The address property should not be null
- Run the test class and verify the tests all pass.
Verification
- The test cases will pass when the exercise is complete