bean-validation

JSR-303 activation in jsonschema2pojo

我是研究僧i 提交于 2020-02-24 11:59:11
问题 There is a place in jsonschema2pojo documentation describing possibility to enable JSR-303 annotations generation. If I understand correctly it can be done via Maven plugin configuration. Could someone show how to accomplish it, which tag in plugin configuration should be used? Thanks to all! 回答1: I think you are looking for the includeJsr303Annotations parameter. See the plugin documentation: includeJsr303Annotations Whether to include JSR-303 annotations (for schema rules like minimum ,

Cascaded bean validation 2.0 not working with nested object inside Map

陌路散爱 提交于 2020-02-24 11:15:43
问题 Although, this question has been answered I'm interested why @Validated is needed for a working cascaded validation of Map<String, @Valid Employee> . Update 2 : For some deeper understanding I've found those posts (One,Two and Three), which explains, that @Validated is neeeded to activate method level validation. With the help of this, collections can be validated, due they are no JavaBeans which are validated instead (JSR 303). Solution : I've updated my code snippets and my repository with

Cascaded bean validation 2.0 not working with nested object inside Map

我只是一个虾纸丫 提交于 2020-02-24 11:14:21
问题 Although, this question has been answered I'm interested why @Validated is needed for a working cascaded validation of Map<String, @Valid Employee> . Update 2 : For some deeper understanding I've found those posts (One,Two and Three), which explains, that @Validated is neeeded to activate method level validation. With the help of this, collections can be validated, due they are no JavaBeans which are validated instead (JSR 303). Solution : I've updated my code snippets and my repository with

Mapping specific constraint validator to specific ContraintViolationException in Jersey

自古美人都是妖i 提交于 2020-02-08 02:37:19
问题 I am trying to create a custom validator and mapped it into a specific constraintViolationException. The reason is I want to create different custom exception for different constraint. For example, if a user is not found in the database, a not found violationException is triggered, while if the user has invalid username, a bad response violationException will be executed instead. @Retention(RUNTIME) @Target({ FIELD, METHOD }) @Constraint(validatedBy = UserNotValidValidator.class) public

hibernate validator without using autowire

青春壹個敷衍的年華 提交于 2020-02-02 15:22:43
问题 I'am currently working on a Jersey project and decided to use Hibernate validator for the parameter validations. All dependencies injected on the Endpoint classes are properly initialized. However for those dependencies in the ConstraintValidator classes, it always throw a NPE. So i followed the guide on Spring+hibernate guide and registered bean id="validator" class="org.springframework.validation.beanvalidation.LocalValidatorFactoryBean" and used the @Autowired annotation for the services

hibernate validator without using autowire

耗尽温柔 提交于 2020-02-02 15:20:10
问题 I'am currently working on a Jersey project and decided to use Hibernate validator for the parameter validations. All dependencies injected on the Endpoint classes are properly initialized. However for those dependencies in the ConstraintValidator classes, it always throw a NPE. So i followed the guide on Spring+hibernate guide and registered bean id="validator" class="org.springframework.validation.beanvalidation.LocalValidatorFactoryBean" and used the @Autowired annotation for the services

What is the best way to validate request in a Spring Webflux functional application

本小妞迷上赌 提交于 2020-01-30 04:51:52
问题 In a traditional web application it is easy to validate the request body in the controller method, eg. ResponseEntity create(@Valid @ResponseBody Post post) { } If it is a MVC application, we can gather the errors by injecting a BindingResult , and decide if there is some validation errors from the input form. In the pages, there are some helpers existed for Freemarker and Thymeleaf to display the messages. But when I come to Webflux and try to use RouterFunction to define the routing in the

@AssertTrue of javax.validation - isn't it supposed to create an error message?

两盒软妹~` 提交于 2020-01-24 06:37:33
问题 I am having the following code in a Spring-MVC command bean: @AssertTrue public boolean isConditionTrue() { return false; } private boolean conditionTrue; My JSP contains the following: <form:errors path="conditionTrue" cssClass="error" /> I would expect to see some error message in the produced HTML... however I see no error message. What do I miss? Thanks!!! 来源: https://stackoverflow.com/questions/7155767/asserttrue-of-javax-validation-isnt-it-supposed-to-create-an-error-message

@AssertTrue of javax.validation - isn't it supposed to create an error message?

[亡魂溺海] 提交于 2020-01-24 06:37:06
问题 I am having the following code in a Spring-MVC command bean: @AssertTrue public boolean isConditionTrue() { return false; } private boolean conditionTrue; My JSP contains the following: <form:errors path="conditionTrue" cssClass="error" /> I would expect to see some error message in the produced HTML... however I see no error message. What do I miss? Thanks!!! 来源: https://stackoverflow.com/questions/7155767/asserttrue-of-javax-validation-isnt-it-supposed-to-create-an-error-message

RESTEasy, CDI, embedded Jetty, bean validation is ignored

喜你入骨 提交于 2020-01-24 01:04:07
问题 I've a Groovy project where I use RESTEasy with Weld and deploy to embedded Jetty. What I can't seem to get working is bean validation. RESTEasy documentation says that adding resteasy-validator-provider-11 along with hibernate validator dependencies ( hibernate-validator, hibernate-validator-cdi, javax.el-api, javax.el ) is enough. But the bean validation is simply ignored by RESTEasy. I curiously also get the following message in the logs: plugins.validation.ValidatorContextResolver -