From the course: Java EE 8 Essential Training

Unlock the full course today

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

Custom constraint validators

Custom constraint validators - Java EE Tutorial

From the course: Java EE 8 Essential Training

Start my 1-month free trial

Custom constraint validators

- [Narrator] When building an application you may come across a scenario where the validation logic is too complex for the built in constraints in the validation API. In that case, there is a mechanism we can use within the bean validation API to handle these situations. We're able to build a custom constraint validator that can handle more advanced logic. So let's get started building our own custom constraint validator and what we're going to do is build a validator that is able to restrict the manufacturers to a specific list that we may have. So nothing out of the box is going to do that for us. And to get started with that we need an annotation that we're going to apply to our manufacturer field and it's going to be very similar to our alphabetic annotation that we created for the other custom validator. So I'm just going to copy that and we can rename it to the permitted manufacturer annotation…

Contents