Questions tagged [javax.validation]

105 questions
1
vote
1 answer

DropWizard non-trivial configuration validation

I have a DropWizard configuration class that has two properties. At least one must be set. That means, both are @Nullable and I need validation on the whole object. public class MessagingStreamConfiguration extends Configuration { …
Ondra Žižka
  • 43,948
  • 41
  • 217
  • 277
1
vote
1 answer

Bean validation fails for Spring Boot application

I have a rest endpoint that is using javax validation with hibernate-validator. @PostMapping(path = "/send") public ResponseEntity send(@Valid @RequestBody DisbursementProcessingDto processingDto, …
peekay
  • 1,259
  • 2
  • 25
  • 49
1
vote
0 answers

Where to specify the group sequence for bean validation

I have custom validations in place that I want to run after all the default validations. I know that we just need to specify the group sequence in @Validated annotation when we want the object to be validated at the controller itself but I want to…
Napstablook
  • 594
  • 1
  • 6
  • 24
1
vote
0 answers

javax validation : group several annotation on the same group

Is it possible for an attribute to group several javax validations on the same group without repeating the declaration ? here is a valid example : @Data public class Poc { @NotNull(groups = {NameForm.class}) private String name; …
Mohamed Taboubi
  • 6,663
  • 11
  • 55
  • 87
1
vote
1 answer

Java Constraint Validation - Validation Not Triggered

I am planning to use ConstraintValidation from javax-validation API pom.xml javax.el javax.el-api 3.0.0
Priyank Thakkar
  • 4,752
  • 19
  • 57
  • 93
0
votes
1 answer

Spring Controller validation of RequestDTO fields as not null is being ignored

I have a Spring Controller with a DTO PlacePixelRequest as the request body in POST request: @RestController public class CanvasController { @PostMapping("/canvas/pixel") public void placePixel(@Valid @RequestBody final PlacePixelRequest…
Shubham Dhingra
  • 186
  • 3
  • 13
0
votes
1 answer

DDD java: Value object validations using javax.validation (when to validation)

I'm trying to create my Size Value Object. import javax.validation.constraints.Min; import javax.validation.constraints.NotNull; import javax.validation.constraints.Positive; @Getter @EqualsAndHashCode @RequiredArgsConstructor(access =…
Jordi
  • 20,868
  • 39
  • 149
  • 333
0
votes
1 answer

Javax Validation extra error on validation fail

I have an 'Answer' object that may be one of many types of answers (email, phone number, name...) I am writing a custom validator to handle the validation and regardless of the answer type the answer text is stored in a single 'value' param. Here is…
Bend
  • 304
  • 1
  • 2
  • 15
0
votes
0 answers

Is there a way to get the container object from BindingResult#FieldError

Is there a way to get hold of the parent object of the offending property? I need to use some other properties to build the error message. There is a BindingResult.getTarget() method, but my 'target' object is pretty big with deep nesting and…
kmansoor
  • 4,265
  • 9
  • 52
  • 95
0
votes
1 answer

How to customise javax.validation.Valid error response

I have this controller: @RequestMapping( method = RequestMethod.GET, value = Endpoints.TRUE_MATCH, produces = {"application/json"}) public ResponseEntity>> getTrueMatch( @Valid Details details) { …
runnerpaul
  • 5,942
  • 8
  • 49
  • 118
0
votes
0 answers

javax.validated not working when using generic method

Here's class GenericService: @Service @Validated public class GenericService { @Autowired OkHttpClient okHttpClient; @Autowired CmdContext cmdContext; public GenericService(OkHttpClient okHttpClient) { this.okHttpClient =…
0
votes
1 answer

java and hibernate validation: validate two method parameters

Here my controller: @PutMapping("{id}") public Mono save( Long id, @RequestBody @Valid @NotNull QdCFPresenter qdcf ) { return this.qdcfService.store(qdcf); } I need to validate that id and qdcf.id are equals. The way I…
Jordi
  • 20,868
  • 39
  • 149
  • 333
0
votes
1 answer

Create a validation method which throw MethodArgumentNotValidException

I'm trying to validate this class : public class RegisterRequest { @Email(message = "format e-mail non valide") @NotNull(message = "ne doit pas être vide") private String email; @NotEmpty(message = "ne doit pas être vide") …
0
votes
0 answers

Spring Controller Advice doesn't receive ConstraintViolationException

The controller throws an ConstraintViolationException since the JPA Entity has a Pattern matching check for field role, which is enforced via Hibernate. But the Controller Advice receives the above exception as TransactionSystemException instead.…
Rpj
  • 5,348
  • 16
  • 62
  • 122
0
votes
1 answer

How to validate a AWS ARN using JPA validator

How to validate AWS ARN using JPA validator with Hibernate as the provider. Should we use a regex pattern For example, we would like to make sure that it starts with arn:aws:iam for the following…
Rpj
  • 5,348
  • 16
  • 62
  • 122