From the course: Java EE: Bean Validation

Unlock the full course today

Join today to access over 22,600 courses taught by industry experts or purchase this course individually.

Pattern, Boolean, and date constraints implementation

Pattern, Boolean, and date constraints implementation

From the course: Java EE: Bean Validation

Start my 1-month free trial

Pattern, Boolean, and date constraints implementation

- [Instructor] Okay, so let's start by adding some constraints to the client class. I'm going to open the client class, which you'll find in the model package. Okay, so here I have the opportunity to use the "email" constraint on the email field, the "past" constraint on the date field, and the "assert true" on the accept terms of service field. So let's add those constraints. So here on the email field I can add the constraint "email", on the date of birth field, I can add the constraint "past", 'cause of course, date of birth must always be in the past, and here on the accept terms of service field, I can add an "assert true", because I want to ensure that the client has ticked the "accept terms of service" tick box. Okay, so now to write the unit test. Let's go down here, okay so let's open the client tests, and scroll down to our two empty tests. Okay this time, I'm going to use a different method for validating an instance. It allows me to efficiently test just one property, and…

Contents