Questions tagged [javax.validation]
105 questions
1
vote
0 answers
How to bypass javax.validation.constraints.Min error in third party libraries?
When I load one third party class, I got exception regarding using javax.validation.constraints.Min on non-getter method. I don't care about that method, I am wondering how to turn off the checking, just let me use the rest of the function as…

BlueDolphin
- 9,765
- 20
- 59
- 74
1
vote
1 answer
No validator could be found for constraint 'javax.validation.constraints.NotEmpty' error in JBOSS
i have a SpringBoot version '2.3.9.RELEASE' application.
Jboss version: jboss-eap-7.1
successfully deployed the application to jboss. when i try to login through my web application, an error occured.
No validator could be found for constraint…

Pamba
- 776
- 1
- 16
- 29
1
vote
1 answer
Does javax validation work with inheritance?
I am trying to validate a model, which is inheriting from another model and this parent model has @NotBlank annotation to validate a parameter. But this validation is bypassed in the controller which is accepting a list of child class objects.
The…

Chiku
- 11
- 2
1
vote
1 answer
Javax nested multiple validations
I have two classes. One is class A, the other class B. Class A has a string field which has a custom validation for checking base 64 encoding. Class B has a list of class A instances. I need to add a custom validator for this list which checks total…

Arnav Sengupta
- 423
- 1
- 7
- 19
1
vote
1 answer
javax.validation.constraints does not work with Spring web
Here is my controller:
import javax.validation.constraints.NotEmpty;
import javax.validation.constraints.NotNull;
@Slf4j
@RestController
@RequestMapping("/auth-api")
public class AuthController {
@PostMapping("/register")
public…

Ilia Reshetnikov
- 3,732
- 1
- 6
- 11
1
vote
1 answer
Can Spring automatically handle validation errors?
I have an endpoint with a @Valid @RequestBody MyPojo pojo argument. When I call the endpoint and trigger a javax.validation failure, the request properly returns with a status 400. However, the response body is empty.
I can add a…

Jorn
- 20,612
- 18
- 79
- 126
1
vote
0 answers
Spring Boot Custom Validator autowired field is null
I am using Spring Boot 2.2.4.RELEASE and I have this custom validator with an autowired service.
@Component
public class CompanyRequiredValidator implements ConstraintValidator {
@Autowired
private CompanyService…

Saminda Peramuna
- 735
- 9
- 22
1
vote
2 answers
Spring validation: method parameter constraint not called
everyone.
So, I have a SpringBoot application with a controller that has several methods, taking the following POJO as a parameter:
package com.example.dto;
import lombok.Data;
@Data
public class MyEntity {
@NotNull
private String fieldA;
…

Alex Kiselev
- 552
- 2
- 7
- 22
1
vote
1 answer
Is it possible to add javax.validation annotation to attributes declared in super type?
I want to define an abstract properties class with standardized name for attributes. That way all properties inheriting will declare the attribute with the same name pattern.
And on a sub class, I wanted to be able to add javax.validation.notNull…

TheBakker
- 2,852
- 2
- 28
- 49
1
vote
1 answer
Spring validation: Difference between validation annotations in Class Attributes VS Constructor Parameters
I have the following Model Object:
@Validated
public class Message implements Serializable {
private static final long serialVersionUID = 9028633143475868839L;
@NonNull
@Size(min = 6, max = 6)
@Pattern(regexp = "[\\d]{6}")
…

MD Ruhul Amin
- 4,386
- 1
- 22
- 37
1
vote
3 answers
Spring-Boot UnitTest: @Value in ConstraintValidator
I'm currently providing coverage - testing the validation of my DTO through MockMVC request call.
I recently introduced a new field in my Registration ConstraintValidator, supportedSpecializations, of which I inject the values from…

MEZesUBI
- 297
- 7
- 17
1
vote
1 answer
Spring DTO validation using ConstraintValidator
The DTO that I use is annotated with javax.validation annotations
For example
@JsonIgnoreProperties(ignoreUnknown = true)
public class StudentDTO {
@NotEmpty
private String name;
@Positive
private Long studentId;
}
What if I have to validate…

Cork Kochi
- 1,783
- 6
- 29
- 45
1
vote
1 answer
Pattern for javax validation annotation reuse when 'combining' two endpoints
I have an API with two entities Foo and Bar with a one-to-many relationship, i.e. each Bar must reference a Foo.
I have endpoints to create both Foo and Bar - these endpoints have their respective DTOs defined with javax validations.
public class…

davnicwil
- 28,487
- 16
- 107
- 123
1
vote
2 answers
Can't read interpolated values in Java validation
In my Spring MVC application I'm making use of @Validated objects in my controllers, using JSR-303. In my Spring application context I have defined a custom MessageSource, to read messages from a resources/messages.properties file.
I'm able to read…

user3673449
- 347
- 2
- 5
- 20
1
vote
1 answer
Validation Constraint, optional field in DTO?
I have a DTO with a couple fields, username, password and email All of them Strings.
I also have a List that I want as an optional, meaning it does not have to be passed in from the form and can be left blank.
This should be valid from the…

Lithicas
- 3,793
- 7
- 23
- 32