1,929 questions
0
votes
0
answers
88
views
Hibernate Validator 8: `addExpressionVariable()` with `#{expMessage}` not being resolved - returns literal string
Question
I'm using Hibernate Validator 8 with Spring Boot 3 and trying to use addExpressionVariable() to safely pass error codes in custom constraint violations. However, the expression #{expMessage} ...
0
votes
0
answers
99
views
Map snake_case query params to an object with Bean Validation
I’m building an API with Spring Boot + Kotlin and I have a scenario where a GET endpoint receives several query parameters. Instead of declaring many @RequestParam in the controller, I’d like to group ...
2
votes
1
answer
201
views
Jakarta Bean Validation not working on collection elements
In my project Spring Boot 3.3.x with Hibernate Validator 8.x and the validation of element list doesn't work. Tell me why?
import jakarta.validation.Valid
import jakarta.validation.Validation
import ...
0
votes
1
answer
57
views
@SpringBootTest -No qualifying bean of type X
I'm trying to limit the scope of a bean (@Component) in my application with no result. I always get this error: "No qualifying bean of type 'com.aexp.mars.egress.gateway.publisher....
1
vote
1
answer
88
views
Can you apply Bean Validation to arbitrary field types?
I can't find it explicitly stated in any of the documentation for JSR303/JSR380 bean validation (Jakarta Validation), but do all fields to which you apply validations have to be "essentially"...
0
votes
0
answers
38
views
JSR bean validation not kicking in for primitive type collection
My controller looks something like this;
@PostMapping(path = RequestMappingConstants.CALCULATE_INTEREST, consumes = MediaType.APPLICATION_JSON_VALUE)
private ResponseEntity<Response> execute(@...
0
votes
1
answer
670
views
Issue with Bean Validation (@ControllerAdvice) using Swagger
This is my Global Exception Handler class:
package com.example.demo.application.handlers;
import java.util.HashMap;
import java.util.Map;
import org.springframework.http.HttpStatus;
import org....
0
votes
1
answer
98
views
Error when using CDI Decorator to decorate the managed Validator
I have a stateless Java EE 7 WebService and want to use the validation framework to validate the incoming data. This all works fine. I then want to transform any ConstraintViolationException to ...
0
votes
0
answers
154
views
How to use a Custom Validation Annotation for custom Error Handling in Spring Boot
I have a custom validation annotation that verifies a fiscal code.
FiscalCode.java
@Retention(RetentionPolicy.RUNTIME)
@Target({ElementType.PARAMETER, ElementType.FIELD})
@Constraint(validatedBy = ...
3
votes
2
answers
274
views
How can I validate a collection as empty in Jakarta Validation?
How can I validate a collection is empty?
// should be empty!
@JsonbTransient
@JsonIgnore
@XmlAnyAttribute
private Map<QName, Object> unknownAttributes;
// should be ...
0
votes
1
answer
472
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 ...
1
vote
1
answer
516
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
1
answer
65
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
1
answer
55
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 ...
1
vote
1
answer
383
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 ...