Skip to main content

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.

0 votes
0 answers
38 views

How can I validate a collection empty?

How can I validate a collection is empty? // should be empty! @JsonbTransient @JsonIgnore @XmlAnyAttribute private Map<QName, Object> unknownAttributes; // should be ...
Jin Kwon's user avatar
  • 21.4k
-1 votes
1 answer
46 views

How to implement custom ConstraintValidatorFactory?

I am trying to perform custom object validation programmatically using Validator interface. Here is a simple example, Model Class (Record) public record Product(String name, int price) implements ...
Vijay Kumar's user avatar
0 votes
1 answer
31 views

How do I include the field name by default in Jakarta validation messages?

I'm using the popular Jakarta bean validation API v3.0.2 + Hibernate Validator. I'm having a lot of trouble debugging validation errors because beans I'm validating have a lot of fields, and the error ...
Kevin's user avatar
  • 1,427
0 votes
0 answers
13 views

GraphQL schema documentation based on SPQR and JSR 303 annotations

I'm using the SPQR Spring Boot for GraphQL. My requirement is that if I have JSR-303/380 annotations in the POJO classes, it should be added as comments in the generated schema. Is there any mechanism ...
slyrit's user avatar
  • 1
0 votes
0 answers
22 views

StackOverflowError in Custom Hibernate Validator with Injected Repository

Calling a repository method inside a custom hibernate validator can lead to a StackOverflowError due to infinite recursion. I am trying to create a custom validator that checks for conflicting ...
Deliel's user avatar
  • 1
0 votes
1 answer
20 views

@Pattern annotation not working if the input is blank

Please refer to the below controller code:- @GetMapping("/fetch) void fetchData( @RequestParam @Pattern(regexp="(^$|[0-9]{10})",message = "Mobile number must be ...
Chris's user avatar
  • 45
0 votes
0 answers
36 views

AbstractMethodError org.hibernate.ejb.HibernatePersistence.getProviderUtil()Ljavax/persistence/spi/ProviderUtil

I have an issue which is about using bean-validation api in Linux Server. The problem is that bean validation works just fine in my local window PC. But when it runs in Cent OS. For some reasons, it ...
taehee lim's user avatar
0 votes
1 answer
45 views

How to add a non-property to a bean class?

I have class with lots of fields, each with a getter and setter. We now need to add logging to some of these methods so I added the new logger-field: @JsonIgnoreProperties(ignoreUnknown = true) public ...
Mikhail T.'s user avatar
  • 3,420
0 votes
0 answers
15 views

How to add a custom MessageValidationInterpolator with custom files?

Im trying to add a custom validation message each time a Jakarta constraint is not valid. Since the client is requiring this message to be in different languages its crucial to determine the language ...
Juan Camacho's user avatar
1 vote
1 answer
99 views

Why isn't Spring kicking in the JSR-303 bean validation?

Wondering why Spring is not getting the Hibernate Bean Validation kicked in. According to the documentation HERE, it requires a MethodValidationPostProcessor in the context and the target spring bean ...
Commander's user avatar
2 votes
1 answer
79 views

Spring Boot bean validator not triggering

I am using the latest stable version of springboot and spring-validator, however the bean validation is not being called at all. Bellow my gradle.kts, Bean and Controller: plugins { java id(&...
Felipe Barata's user avatar
-1 votes
1 answer
73 views

Possible to use one of the existing standard Java constraint annotations (`@Size`) on my custom Java type?

Is it possible to use one of the existing standard Java constraint annotations (@Size) on my new Java type (MyType)? I don't want consumers of my framework to have to use non-standard annotations in ...
bobbyrne01's user avatar
  • 6,563
0 votes
1 answer
50 views

How to pass constraint values for annotaions dynamically through expression languange. Eg: @Size("${app.name.maxSize}")

Is it possible for the arguments passed to the constraint annotations to be passed dynamically using expression language. Its a generic requirement that could apply to any annotation, in example given ...
Pushkar Desai's user avatar
1 vote
0 answers
601 views

Clarification required on Spring Boot validator

Folks, I have a project in SpringBoot 3.2.2 and am trying to add validators (@NotEmpty) to the input - but, it doesn't seem to work. Here are the things that I have already done / tried. Added the ...
Vijay Venkat's user avatar
0 votes
2 answers
63 views

Bean Validation API, possible to dynamically indicate to validator to ignore a specific constraint annotation on a specific field of POJO

I have a POJO with some fields annotated with @NotEmpty: public class SampleFormInputDTO { @NotEmpty private String textarea; private int myInt = 0; @NotEmpty private String myText = &...
bobbyrne01's user avatar
  • 6,563

15 30 50 per page
1
2 3 4 5
129