Questions tagged [hibernate-validator]

Hibernate Validator is the reference implementation for JSR 380 - Bean Validation 2.0

Hibernate Validator is the reference implementation for JSR 380 - Bean Validation 2.0 which defines an API and model for JavaBean validation. Validation metadata is provided via annotations. The metadata can be overridden and extended through the use of XML.

The API is not bound to any specific application tier or programming model/paradigm. It available for server-side validation (for a web application for example) as well for client-side apps (for example, those written in Swing).

To get started with Hibernate Validator visit the Getting started page.

1211 questions
261
votes
15 answers

Cross field validation with Hibernate Validator (JSR 303)

Is there an implementation of (or third-party implementation for) cross field validation in Hibernate Validator 4.x? If not, what is the cleanest way to implement a cross field validator? As an example, how can you use the API to validate two bean…
Bradley Dwyer
  • 8,102
  • 5
  • 32
  • 28
136
votes
16 answers

javax.validation.ValidationException: HV000183: Unable to load 'javax.el.ExpressionFactory'

I try to write very simple application with hibernate validator: my steps: Added following dependency in pom.xml: org.hibernate hibernate-validator
gstackoverflow
  • 36,709
  • 117
  • 359
  • 710
63
votes
9 answers

Hibernate validator: @Email accepts ask@stackoverflow as valid?

I'm using the @Email annotation to validate an e-mail address. The issue I'm having is that it's accepting things like ask@stackoverflow as a valid e-mail address. I guess this is because they want to support intranet addresses, but I can't seem to…
jack
  • 1,902
  • 5
  • 32
  • 43
56
votes
5 answers

java.lang.NoSuchMethodException: userAuth.User.()

I have the class with validation: public class User { @Size(min=3, max=20, message="User name must be between 3 and 20 characters long") @Pattern(regexp="^[a-zA-Z0-9]+$", message="User name must be alphanumeric with no spaces") private…
Lesya Makhova
  • 1,340
  • 3
  • 14
  • 28
53
votes
5 answers

JSR 303: How to Validate a Collection of annotated objects?

Is it possible to validate a collection of objects in JSR 303 - Jave Bean Validation where the collection itself does not have any annotations but the elements contained within do? For example, is it possible for this to result in a constraint…
cam
  • 681
  • 1
  • 6
  • 7
42
votes
2 answers

AbstractMethodError on deploying Spring 4.0 in Tomcat 6

I am getting below exception on deploying Spring 4.0.1 app in Tomcat 6.0.37: SEVERE: Exception sending context initialized event to listener instance of class…
Vikas Sharma
  • 1,235
  • 2
  • 27
  • 53
41
votes
6 answers

Hibernate Validation of Collections of Primitives

I want to be able to do something like: @Email public List getEmailAddresses() { return this.emailAddresses; } In other words, I want each item in the list to be validated as an email address. Of course, it is not acceptable to annotate…
scrotty
  • 833
  • 2
  • 10
  • 17
36
votes
2 answers

Control validation annotations order?

A field has two validation annotations @NotEmpty @Length(min=3,max=100) String firstName; Observation If that field is left empty, then the resulting violations vary in order: sometimes the @NotEmpty is violated first other times the @Length is…
Mahmoud Saleh
  • 33,303
  • 119
  • 337
  • 498
34
votes
3 answers

Spring MVC 3 Validation - Unable to find a default provider

I get an error when trying to set up Spring MVC validation. javax.validation.ValidationException: Unable to find a default provider I read in the documents that the default provider they use is the hibernate-validator. Do I need to include this…
Kyle
  • 21,377
  • 37
  • 113
  • 200
33
votes
4 answers

javax.servlet.ServletException: HV000030: No validator could be found for type: java.lang.Integer

I have to update information in my database. FacadePatient.java class code: public Patient update(Patient p) { Patient pat = em.find(Patient.class, p.getPatientId()); p.setPatientPhone(pat.getPatientPhone()); …
Héla
  • 359
  • 1
  • 3
  • 6
32
votes
6 answers

javax.validation.ValidationException: Unable to find default provider

I am currently working on Spring MVC web app and trying to hook up validation using the @Valid annotation. When I fire up the application I'm getting the following exception: javax.validation.ValidationException: Unable to find a default provider I…
Caps
  • 1,493
  • 1
  • 16
  • 24
29
votes
2 answers

Spring Validation vs Hibernate Validation

I am confused between the two now. I know Hibernate Validator 6 is the reference implementation for Bean Validation 2.0 specs. It supports Grouping, Internationalization of error messages, Custom Method Validations etc. Question is does Spring 5…
Nova Guy
  • 505
  • 2
  • 9
  • 16
29
votes
9 answers

Include field name inside error message using Hibernate Validator

I'm using Hibernate Validator 4.2.0.Final and I'm looking for the simplest way to include class field name in my error message. What I found is the following thread Using a custom ResourceBundle with Hibernate Validator. According to this I should…
BartoszMiller
  • 1,245
  • 1
  • 15
  • 24
28
votes
5 answers

How do I import javax.validation into my Java SE project?

I'm trying to add constraints checking, as described here How to specify the cardinality of a @OneToMany in EclipseLink/JPA
simpatico
  • 10,709
  • 20
  • 81
  • 126
27
votes
3 answers

java.lang.NoSuchMethodError: javax.validation.BootstrapConfiguration.getClockProviderClassName

JDK: 1.8.0_131 Tomcat: 8.0.27.0 Hibernate Validator: 6.0.7.Final + all the dependencies downloaded from: Hibernate Validator 6 @POST @Consumes(MediaType.APPLICATION_JSON) @Produces(MediaType.APPLICATION_JSON) public…
asabd
  • 299
  • 1
  • 5
  • 9
1
2 3
80 81