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.
Null constraints introduction
- [Instructor] Okay, so now we're in the IDE. Let's navigate to the client class, which we'll find in the model package. Now this is the client class backend bean, and this bean's fields reflect the fields on the "create new client" form. So when a new client is created, data that is entered in that form, is passed through to the backend bean, and the new client instance is created, and when this happens, bean validation occurs. So what I want to do, is I want to ensure no null values enter into my application, via this form. And to do this, I need to annotate the fields that might be null. So taking a look at this class, you can see clearly that the fields that could be null are the name fields, the email fields, and the date of birth field. Now it is unlikely that the ID field will be null, as this is set internally, and the terms of service field is false by default. So it cannot be set to null by the user doing so from the web form. Okay, so lets add these constraints. The first…
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
-
-
-
-
-
-