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 validation annotations - Java EE Tutorial
From the course: Java EE 8 Essential Training
Custom validation annotations
- [Instructor] Within the Bean Validation API we're able to apply constraint annotations on other annotations. It's a way of building a custom validator within the Bean Validation API. This is very useful if we have some validation that's going to be applied over and over throughout our application. So for instance, here we have a regex that basically checks whether or not a string is alphabetic. That could be a very common validation. So let's go ahead and build another annotation that will apply that validation and make it reusable throughout our application. So what we're going to do within our com.linkedin package in the EJB project, we're just going to open the new dialog and we're going to create a plain annotation. So just select the Annotation under Java, hit Next, and then we're going to name this annotation Alphabetic. You'll want to set the retention to runtime. And then you can go ahead and select the Type…
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.