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.
bean-validation
1,930
questions
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 ...
-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 ...
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 ...
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 ...
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 ...
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 ...
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 ...
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 ...
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 ...
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 ...
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(&...
-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 ...
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 ...
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 ...
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 = &...