Questions tagged [javax-validation]
11 questions
2
votes
1 answer
javax.validation annotation for string base64
I have a rest service with my request body bean annotated with javax.validation like @NotBlank @NotNull @Pattern etc., and in one specific field I receive a file encoded as a string base64,
so, is there an annotation, or how could I write a custom…

Alfredo Morales
- 75
- 9
1
vote
1 answer
Spring @RequestHeader validate for blank string
I have a spring service that receives a header parameter like this:
@RequestHeader(name = "token", required = true) String token
but it only validates if the header is present and not if it is blank or just spaces,
if I add @NotBlank or @Valid…

Alfredo Morales
- 75
- 9
0
votes
1 answer
Dynamic Validation message in Constraint Validation of Enums
I was trying to Validate the Enum before Request Processing,
EnumValidator.java
@Target({ElementType.FIELD, ElementType.PARAMETER})
@Retention(RetentionPolicy.RUNTIME)
@Constraint(validatedBy = EnumValidatorImpl.class)
public @interface…

user3309305
- 181
- 1
- 7
0
votes
1 answer
Hibernate Validator: validate collection items before validating the collection itself
Problem:
I have a bean under validation by the Hibernate Validator.
That bean has a property with List type, and this property has custom validator (1). Elements of this List also have their own custom validators (2).
I need the elements of this…

Дмитрий Брикман
- 51
- 5
0
votes
1 answer
Data Class Validations not working in Micronaut
Context:
I'm using micronaut version 3.4.2 and Kotlin 1.7.22.
I have a Data class in another project which I download as a dependency Jar. The javax field validations are not working in the controller layer.
My data…

Aditya
- 33
- 6
0
votes
0 answers
Unit test doesn't work for Spring path variable validation
I'm setting up an unit test to ensure that controller method's path variable javax constraints are working as expected with all the required dependencies.
Controller class :
@RestController
@RequestMapping("users")
@Validated
@Slf4j
public class…

JsbDev
- 23
- 6
0
votes
2 answers
How to use @Valid with @PutMapping when Request Body is a List of dataclass in Kotlin Spring boot?
@Valid is not working with @PutMapping where Request Body is List of dataclass in Kotlin Spring boot
have added the library for it in the gradle.build.kts
implementation("org.springframework.boot:spring-boot-starter-validation")
then tested for the…

Navin Kumar
- 1
- 1
0
votes
1 answer
Adding @NotBlank and Pattern constraints with different error messages
@NotBlank(message = "userCategory is missing")
@Pattern(regexp = "Single|Married", message = "userCategory is invalid")
private String userCategory;
Currently when validation happens, it gives me two error messages when I provide a…
0
votes
1 answer
Why is validation property path appended with ?
When using Hibernate Validator (via the javax.validation interfaces), I'm seeing a strange phenomenon in the property paths of nested objects when there are violations.
This demonstrates it:
@Documented
@Retention(RUNTIME)
@Target({ METHOD, FIELD,…

E-Riz
- 31,431
- 9
- 97
- 134
0
votes
1 answer
Java Bean Validation using @DecimalMin @DecimalMax but also allow empty string?
I came across a strange case that given following model class:
@DecimalMin("-10")
@DecimalMax("10")
String position;
And the client has a request that sets position to be an empty string "" and expects the validation to pass. This is something I…

夢のの夢
- 5,054
- 7
- 33
- 63
-1
votes
1 answer
Validate Additional parameters in Requestbody for Springboot request and throw 400
@Data
public class Employee{
@NotNull
@NotBlank
private string id;
@NotNull
@NotBlank
private string name;
}
@RestController
@Validated
class EmployeeController{
@postMapping(consumes="json", produces="json")
public ResponseEntity…

Kannan TK
- 19
- 1
- 5