Questions tagged [bean-validation]

Bean Validation, previously commonly called just "JSR-303", is an annotation based validation framework for javabean properties and parameters of arbitrary methods. Hibernate Validator is the reference implementation and the most widely used one.

Online resources

1913 questions
8
votes
3 answers

Resteasy Bean Validation Not Being Invoked

Problem Background I have a Resteasy service that uses Spring through Resteasy's SpringContextLoaderListener. This is built on Resteasy version 3.0-beta-6. I would like to use bean validation on the incoming requests, but I can not get Resteasy to…
gregwhitaker
  • 13,124
  • 7
  • 69
  • 78
8
votes
1 answer

How does it work with bean validation messages and i18n in JSF2?

I created validation messages(ValidationMessages.properties) file to make the i18n possible in my project. It looks like: pwtNumber.error=PWT Number error.. I defined it in…
Kayser
  • 6,544
  • 19
  • 53
  • 86
8
votes
3 answers

How to solve cast issue java.lang.ClassCastException: $Proxy cannot be cast to NotEmpty which is annotation

I have a REST service project integrated with spring. I am trying to integrate bean validation. I have made a custom annotation: /** * Denotes a field as being no empty. * * @author pguzun */ @Target({METHOD, FIELD, ANNOTATION_TYPE}) …
pguzun
  • 171
  • 1
  • 1
  • 6
8
votes
2 answers

How to do client side validation with annotated rules on domain classes (RequestFactory)?

I've been developing a project with GWT 2.4 and looking for a way to validate (JSR 303) my client (proxy) classes without recreate annotations from my domain classes (server side). I know that there is an example suplied with GWT trunk code…
8
votes
3 answers

How can I make Spring show different validation bundle-based messages for the same validator on a class?

First, let me explain that I'm using Spring MVC 3.1.1, and Hibernate validation 4.2.0. I'm using validation annotations for various forms in my Spring application. Since my application needs to be localized, I've been using a resource bundle for…
Scott Arrington
  • 12,325
  • 3
  • 42
  • 54
7
votes
2 answers

Difference between DataBinder and ConversionService in Spring

I am experiencing some confusion in the use and purpose of Spring's DataBinder and ConversionService with regards to binding web requests to model objects. This has arisen because I have recently tried to use the JSR-303 validation by adding . Prior…
jtsnr
  • 1,180
  • 11
  • 18
7
votes
1 answer

Multiple validators on one field with JSF bean validation

i am trying to make multiple validation one one field @NotBlank(message = "{name.required}") @Max(value = 25, message = "{long.value}") public String name; JSF:
Mahmoud Saleh
  • 33,303
  • 119
  • 337
  • 498
7
votes
1 answer

JSF: How validate fields and return error messages by bean validation?

I have a contact form and I have some fields that are validated by bean validation, how could I return bean validation error messages after submitting? For example:
Valter Silva
  • 16,446
  • 52
  • 137
  • 218
7
votes
0 answers

OpenAPI Generator Maven Plugin Bean Validation MinProperties Validation

I have a Spring Boot (2.4.0) REST service, using Java 11. The endpoints and objects are generated from an OpenAPI 3.0.3 file using openapi-generator-maven-plugin v5.0.1 In the API there is a GET request that takes two query params. At least one of…
CeeTee
  • 778
  • 1
  • 9
  • 17
7
votes
2 answers

Cascaded bean validation 2.0 not working with nested object inside Map

Although, this question has been answered I'm interested why @Validated is needed for a working cascaded validation of Map. Update 2: For some deeper understanding I've found those posts (One,Two and Three), which explains,…
Theiaz
  • 568
  • 6
  • 24
7
votes
2 answers

How to validate bean on Spring's WebClient?

I guess the answer is no, as all references to Bean Validation in the documentation are related to the server side. Is there any support for Bean Validation on the client's side? So that I can validate my entities before even sending them to the…
antonro
  • 449
  • 2
  • 4
  • 10
7
votes
1 answer

JSR-303 Annotating Field vs Getter

When using JSR-303 annotations to perform bean validation, what is the difference between annotating the field versus the getter? Is one approach recommended over the other? Annotation on field public class Person { @NotBlank private String…
kernelpanic
  • 1,158
  • 5
  • 17
  • 36
7
votes
1 answer

method marked with @AssertTrue is not invoked

I have following class to validate: @Document(collection = "settings") public class Settings { @NotEmpty private String[] allowableExtensions; ... @AssertTrue(message = "Each extension must be alphanumeric string with length {2,4}") …
gstackoverflow
  • 36,709
  • 117
  • 359
  • 710
7
votes
1 answer

Is there a way to integrate java bean validation api With Spring RestTemplate

Is there a way to integrate spring RestTemplate with JavaBean validation api. ? I know there is a integration for spring controller. you can put @Valid on request body param and if Employee is not valid you will get MethodArgumentNotValidException…
user1321466
  • 1,889
  • 2
  • 21
  • 29
7
votes
4 answers

Bean Validation with JAX-RS (rest-easy): parameter name not recognized

I'm using JAX-RS resources with Bean Validation and integration between these two works as expected. However, the default error messages generated in case of a validation error report parameter names as arg0, like…
omilke
  • 827
  • 9
  • 20