bean-validation

ConstraintViolationException handler isn't executed in Micronaut

扶醉桌前 提交于 2021-02-19 03:48:04
问题 I have a ConstraintViolationException handler class that looks like this: @Produces @Singleton @Requires(classes = {ConstraintViolationException.class, ExceptionHandler.class}) public class ConstraintsViolationsExceptionHandler implements ExceptionHandler<ConstraintViolationException, HttpResponse> { @Override public HttpResponse handle(HttpRequest request, ConstraintViolationException exception) { return HttpResponse .status(HttpStatus.FORBIDDEN) .contentType(MediaType.APPLICATION_JSON)

Is there a way to integrate java bean validation api With Spring RestTemplate

≡放荡痞女 提交于 2021-02-19 01:15:56
问题 Is there a way to integrate spring RestTemplate with JavaBean validation api. ? I know there is a integration for spring controller. you can put @Valid on request body param and if Employee is not valid you will get MethodArgumentNotValidException exception . which you can handel in exception handler class. @PostMapping(value = "/add", produces = APPLICATION_JSON_VALUE) public ResponseEntity<String> addEmployee( @RequestBody @Valid Employee emp) { //... } But what I want is similar way to

Is there a way to integrate java bean validation api With Spring RestTemplate

╄→尐↘猪︶ㄣ 提交于 2021-02-19 01:08:50
问题 Is there a way to integrate spring RestTemplate with JavaBean validation api. ? I know there is a integration for spring controller. you can put @Valid on request body param and if Employee is not valid you will get MethodArgumentNotValidException exception . which you can handel in exception handler class. @PostMapping(value = "/add", produces = APPLICATION_JSON_VALUE) public ResponseEntity<String> addEmployee( @RequestBody @Valid Employee emp) { //... } But what I want is similar way to

Is there a way to integrate java bean validation api With Spring RestTemplate

旧巷老猫 提交于 2021-02-19 01:07:25
问题 Is there a way to integrate spring RestTemplate with JavaBean validation api. ? I know there is a integration for spring controller. you can put @Valid on request body param and if Employee is not valid you will get MethodArgumentNotValidException exception . which you can handel in exception handler class. @PostMapping(value = "/add", produces = APPLICATION_JSON_VALUE) public ResponseEntity<String> addEmployee( @RequestBody @Valid Employee emp) { //... } But what I want is similar way to

Spring @Validated annotation prevents @ConfigurationProproperties value injection, why?

五迷三道 提交于 2021-02-18 19:32:57
问题 I am trying with @ConfigurationProperties and I find two things: for tests to work, I have to put configuration properties files (yml) in test package; setters and an empty constructor are required. If I annotated the class with @Validated , injection just fails with all null values. If you say the first one is understandable, and the second one? Why? The purpose is to validate configuration properties injection, so that crucial properties values should not be absent when the application

Spring @Validated annotation prevents @ConfigurationProproperties value injection, why?

半腔热情 提交于 2021-02-18 19:31:10
问题 I am trying with @ConfigurationProperties and I find two things: for tests to work, I have to put configuration properties files (yml) in test package; setters and an empty constructor are required. If I annotated the class with @Validated , injection just fails with all null values. If you say the first one is understandable, and the second one? Why? The purpose is to validate configuration properties injection, so that crucial properties values should not be absent when the application

Why my custom javax.faces.context.ExceptionHandler doesn't handle javax.validation.ConstraintViolationException

北战南征 提交于 2021-02-11 14:27:21
问题 My custom exception handler is not being invoked by the container to intercept (checked or unchecked) exceptions (I verified it through the debugger). I have this Entity bean class with @Email annotation for the email field, and when the user types in an invalid email through the JSF page, an error message is being displayed, however, the error message is not the one I set through the custom exception handler class, rather it is the one I have set as the default message for the @Email

How to use @NotNull with spring boot?

跟風遠走 提交于 2021-02-08 20:00:08
问题 I have this dependency: <dependency> <groupId>org.hibernate.validator</groupId> <artifactId>hibernate-validator</artifactId> </dependency> Which have it's version managed by <parent> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-parent</artifactId> <version>2.0.4.RELEASE</version> </parent> And I have this piece: import javax.validation.constraints.NotNull; //other imports ommited @Component @ConfigurationProperties(prefix = "collector") public class

bean validation (JSR 303) for primefaces not working

十年热恋 提交于 2021-02-08 06:52:39
问题 I'm using: Primefaces 6.1 JSF: 2.2.10 javax.validation:1.1.0.Final validator impl: hibernate-validator 5.0.1.Final GAE: 1.9.52 I follow the example for CSV (Client Side Validation) using backend bean from: https://www.primefaces.org/showcase/ui/csv/bean.xhtml The expected result should be: And what I get right now: The bean validation is not working. I have below configure in web.xml <context-param> <param-name>primefaces.CLIENT_SIDE_VALIDATION</param-name> <param-value>true</param-value> <

Injecting Spring Dependencies into ConstrantValidator

吃可爱长大的小学妹 提交于 2021-02-05 12:24:00
问题 I'm using Bean Validation. I have a custom validator @MyValidator that needs to look up a value with an injected Spring managed DAO object. How can I get access to this? Spring isn't injecting the DAO into my "MyValidator" object. @Component public class CodeListValidator implements ConstraintValidator<CodeList, String> { @Autowired private ICodeListCommonService codeListCommonService; private CodeListEnum codeListID; @Override public void initialize(CodeList constraintAnnotation) { this