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
From the course: Java EE: Bean Validation
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…
Practice while you learn with exercise files
Download the files the instructor uses to teach the course. Follow along and learn by watching, listening and practicing.
Contents
-
-
-
-
-
Built-in constraints introduction5m 4s
-
(Locked)
Null constraints introduction2m 4s
-
(Locked)
Null constraints implementation5m 8s
-
(Locked)
Numerical constraints introduction2m 33s
-
(Locked)
Numerical constraints implementation6m 10s
-
(Locked)
Pattern, Boolean, and date constraints introduction2m 4s
-
(Locked)
Pattern, Boolean, and date constraints implementation6m 24s
-
-
-
-
-
-