Setting validation failure messages locally may not be suitable for your project and setting them globally may be a better solution. One of many benefits won by setting failure messages in a property file is that they can form a resource bundle and therefore be internationalized.
- Validation messages can be configured…at the global level if that suits your use case.…The messages are all located in one file…that must be on the class path.…This is where the API looks for property files…that contain all of your custom messages.…So in my project, all files located in…the resource directory are on the class path,…so this is where I'm going to put my validation messages.…So let's navigate to the resources location.…So I'm going to create a file called…ValidationMessages.properties.…
It's just a plain text file, nothing special,…but it should be named this way.…So just right click, new, and do file, and then…it's going to be called ValidationMessages.properties.…Now here is where I will configure my custom messages.…I do this by specifying a message key…and associating a custom message.…And it's simply displayed like this:…a key and message, it's a simple key value pair.…
But how do I know what the key name is?…Well, you need to dive into the constraint…annotation code itself and have a look.…
In this course, you can journey through the many constraints that are built into the 2.0 version of the Bean Validation API, as well as the additional constraints provided by the Hibernate Validator 6.0. Learn Bean Validation in a practical way while you build a functioning web application. Instructor Alex Theedom shows how to extend the API with custom constraints and how to internationalize validation failure messages. Plus, learn advanced techniques such as cross-field and cross-parameter validation, and how Bean Validation integrates with other Java EE technologies such as JAX-RS, Java Persistence API (JPA), and JavaServer Faces (JSF). By the end of this course, you will have gained practical experience of using Bean Validation in a real web application and be able to implement what you have learned in your own Java applications.
- What is Bean Validation?
- Applying the built-in constraints
- Applying Hibernate constraints
- Designing custom constraint validators
- Managing and configuring validation failure messages
- Creating custom composite constraints
- Creating custom validation constraints
- Cross-field and cross-parameter validation
- Integration with RESTful web services (JAX-RS)
Skill Level Intermediate
WebSocket Programming with Java EEwith Alex Theedom1h 29m Intermediate
Java Platforms Compared: SE vs EE vs MEwith Peggy Fisher25m 38s Intermediate
1. What Is Bean Validation?
2. Course Project Introduction
3. Applying Built-In Bean Validation Constraints
4. Applying Hibernate Bean Validation Constraints
5. Designing Custom Constraint Validators
6. Bean Validation Failure Messages
7. Advanced Bean Validation Features
Advanced constraint usage1m 52s
Next steps1m 50s
- Mark as unwatched
- Mark all as unwatched
Are you sure you want to mark all the videos in this course as unwatched?
This will not affect your course history, your reports, or your certificates of completion for this course.Cancel
Take notes with your new membership!
Type in the entry box, then click Enter to save your note.
1:30Press on any video thumbnail to jump immediately to the timecode shown.
Notes are saved with you account but can also be exported as plain text, MS Word, PDF, Google Doc, or Evernote.