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

Null constraints introduction

From the course: Java EE: Bean Validation

Start my 1-month free trial

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…

Contents