bean-validation

How to combine JSR-303 and Spring Validator class in a service layer?

泪湿孤枕 提交于 2019-12-29 05:32:07
问题 I have some model class public class Account { @Email private String email; @NotNull private String rule; } and spring-validator public class AccountValidator implements Validator { @Override public boolean supports(Class aClass) { return Account.class.equals(aClass); } @Override public void validate(Object obj, Errors errors) { Account account = (Account) obj; ValidationUtils.rejectIfEmpty(errors, "email", "email.required"); ValidationUtils.rejectIfEmpty(errors, "rule", "rule.required");

@GroupSequenceProvider and group is a superset

只谈情不闲聊 提交于 2019-12-25 02:42:34
问题 Simple class Person.class class Person { @NotNull(groups = {PartlyCheck.class}) private String name; @NotNull(groups = {FullCheck.class}) private String adress; private boolean isFullCheck; } Check interfaces public interface PartlyCheck{} public interface FullCheck extends PartlyCheck{} I use two approach: if(person.isFullCheck) { validator.validate(person, FullCheck.class); else { validator.validate(person, PartlyCheck.class); } 1. If isFullCheck=true used both checks (FullCheck.class and

Jsr303 Bean Validation error message without prefix of form and field name

两盒软妹~` 提交于 2019-12-25 01:48:49
问题 I'm using bean validation and extval validation. I've created a properties file called ValidationMessages.properties inside my class path. inside this file i customized the defult messages , for example: javax.validation.constraints.Size.message=this is a test messgae when the fieild is being validated I can see the message I worte, but the problem is that I also see the field and form name before the message ' like this: formName:fieldName this is a test . I want to remove this prefix. when

Dumping bad requests

你离开我真会死。 提交于 2019-12-25 00:27:23
问题 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<JerseyViolationException> . But I need to have the complete request (headers, body) and not only ConstraintViolations . 回答1: You can inject ContainerRequest into the ExceptionMapper . You need to inject it as a javax.inject.Provider though, so that you can lazily retrieve it. Otherwise you will run into

Implementing cross-validation in java

假如想象 提交于 2019-12-24 20:35:22
问题 I use Spring Roo + jpa + hibernate and I would like to implement cross-validation (validation of several fields at the same time) in my application. I am not sure how to go about implementing it. Can anyone please advise me and/or direct me to relevant documentation? 回答1: Have a look at Hibernate Validator, which allows entity validation (using annotations). http://www.hibernate.org/subprojects/validator.html In short, you annotate your field constraints by placing hibernate validator/ JPA

Why Spring Message Interpolation Argument Replacement using Hibernate Validator don't work?

可紊 提交于 2019-12-24 10:44:41
问题 I used Spring4 + Hibernate5 Validator to do the validation. I don't want use the default ValidateMessage.properties, so I define my own message properties under the I18N directory in the classpath root directory, the config information is below: <bean id="messageSource" class="org.springframework.context.support.ResourceBundleMessageSource"> <property name="basenames" value="I18N.messages,I18N.validation.ValidationMessages" /> <property name="defaultEncoding" value="UTF-8" /> <!-- Set whether

HTTP Status 500 - Handler processing failed; nested exception is java.lang.AbstractMethodError:

此生再无相见时 提交于 2019-12-24 05:57:43
问题 Please help me with learning the basics of Spring 3 MVC better, I was trying to learn about Spring JSR 303: Bean Validation and could not solve the below problem at all, I have spent over a day on this already :( I want a simple validation to work here. The name, password and email fields in hello.jsp can not be left blank, that's quite is the objective. As of now every time the hello.jsp is attempted to be submitted with all the fields as blank the below error is encountered HTTP Status 500

How to use bean validation 1.1 in JBoss EAP 6.4.0?

ぃ、小莉子 提交于 2019-12-24 05:23:14
问题 I have a simple restful web service that uses Bean Validation 1.1 (and Hibernate Validator 5.1.3 as the implementation) and I'm deploying it on JBoss EAP 6.4.0. Since JBoss 6.4 comes bundled with Bean Validation 1.0 and its implementation library (Hibernate Validator 4.3.2), there is a conflict and none of service calls work. Below is the error that I get: java.lang.NoSuchMethodError: javax.validation.Validator.forExecutables()Ljavax/validation/executable/ExecutableValidator; org.apache.cxf

JSF 2 dynamic form and bean validation JSR 303

徘徊边缘 提交于 2019-12-24 02:21:35
问题 I generate a dynamic form starting from annotated bean. The same bean is annotated for validation using Hibernate Validator. The form is correctly rendered but when the form is submitted the validation step it's not executed. If I write the same form with jsf tag the validation works properly. Any idea? The form page: <body> <ui:composition template="/template/basetheme_one_col.xhtml"> <ui:define name="title">#{__g4cController.entityClassName}</ui:define> <ui:define name="main_area"> <h2>#{_

JSR-303 compatible bean validator for Android

孤街浪徒 提交于 2019-12-24 01:27:32
问题 Is it really possible that there is no JSR-303 compatible validator for Android around? Hibernate validator seems not compatible with Android (ClassNotFound Exception) and then... I could not find anything else. I found Metawidget - but on their Website they say "Metawidget comes with a UI component native to your existing front-end" - I don't need additional UI components. Here is what I have on the backend: final String wrongJson = "{\"name\":\"notavalidemail\"}"; final Gson gson = new Gson