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.

Online resources

1913 questions
0
votes
0 answers

Custom bean validator throws null pointer in unit test

I have created an example custom constraint to explore the hibernate bean validation implementation. The constraint itself is fairly simple; given a particular String and an enum, the validator uses regex to check whether the String matches a…
jbailie1991
  • 1,305
  • 2
  • 21
  • 42
0
votes
2 answers

problem when using javax.validation.Validator and others

I'm trying to validate something using the GWT BeanValidation but these two lines are giving me some trouble: Validator validator=Validation.buildDefaultValidatorFactory().getValidator(); Set> violations =…
Neets
  • 4,094
  • 10
  • 34
  • 46
0
votes
1 answer

How to get error list by using BindingResult for @Valid List

I have a Spring controller method that I wanna validate using @Valid and get the BindingResult errorlist. But In my @RequestBody have List list. @PostMapping(path="/save/inouts") public ResponseEntity> saveInouts(@Valid…
IsuruK
  • 55
  • 6
0
votes
1 answer

How to get a ConstraintViolation

Something's missing in my test case linked below to get back some ConstraintViolation after setting null to a method parameter annotated with…
0
votes
0 answers

Is it possible to manually trigger a ConstraintValidationError to use its error template?

In my API project, I have a custom ConstraintValidator to check whether e-mail addresses aren't already associated with another account. Interface: import javax.validation.Constraint; import javax.validation.Payload; import…
aardbol
  • 2,147
  • 3
  • 31
  • 42
0
votes
1 answer

How can I bean-validate on a char?

I just found that @Pattern might work (only) with CharSequences. How can I validate a single char? //@Pattern(regex = "[YN]") // @@? private char someYn; // 'Y' or 'N' Will it blend? Using an AttributeConverter is not an option. Oh, is a single…
Jin Kwon
  • 20,295
  • 14
  • 115
  • 184
0
votes
2 answers

Having trouble in Spring MVC form validation using hibernate-validator and JSR-303

I wan to use hibernate-validator to perform form validation but following error occur. I saw previous solutions like changing dependency i tried all but having same error. > This is the below error message: HTTP Status 500 - Servlet.init() for…
ndj
  • 27
  • 9
0
votes
1 answer

Cannot find the declaration of element 'constraint-mappings'

Reading documentation: https://docs.jboss.org/hibernate/stable/validator/reference/en-US/html_single/#section-mapping-xml-constraints I removed one long bean definition for brevity, then source looks like below. When executed, I get: Caused by:…
Martin Mucha
  • 2,385
  • 1
  • 29
  • 49
0
votes
1 answer

custom validation using Javax or Hibernate validation for collections

I am using validation-api-1.1.0.Final and hibernate-validator-5.3.6.Final. I would like to do validation for the below case, Information received from the client, "BookInfo":[ { "key":"book.name", …
VelNaga
  • 3,593
  • 6
  • 48
  • 82
0
votes
1 answer

Dumping bad requests

I have a service implemented with Dropwizard and I need to dump incorrect requests somewhere. I saw that there is a possibility to customise the error message by registering ExceptionMapper. But I need to have the complete…
Oleg Pavliv
  • 20,462
  • 7
  • 59
  • 75
0
votes
1 answer

Spring ConstraintValidator vs MultipartFile

I want to check file extension on upload usin ConstraintValidator. If the file extension is not as specified in the annotation, then the user should get common constraint validation error response. But when it happens this exception…
0
votes
1 answer

How to do conditional validation in spring boot?

I am developing a Spring REST application. I have a DTO private String name; @ private String nationality; private String matchType; private List ncFields = new ArrayList(); // Getters and Setters I have 3 tables Field Table Name…
user3343543
  • 143
  • 2
  • 14
0
votes
1 answer

Spring Boot - Bean Validation 2.0 Validation of a list of objects

I am using springBoot 2 and I am trying to validate the objects in a List via: @RequestMapping(value = "/bets", produces = {"application/json"}, consumes = {"application/json"}, method = RequestMethod.POST ) void postBets(@RequestBody…
JoeyHolloway
  • 458
  • 7
  • 19
0
votes
2 answers

Default globalErrors in Spring

I want to know if there are any default globalErrors in Spring framework. I need to create my own custom validator by implementing org.springframework.validation.Validator interface. And there I add a globalError by errors.reject(). In controller…
0
votes
3 answers

Spring boot 2.0.X properties exceptionhandler response ascii?

everybody,i am using boot 2.0.x,project encoding and charset are UTF-8, request and response as same,but when using bean validation 2, to convert error msg,it shows ascii? 1:defined a bean such as BeanValidation.java: @Data public class…