bean-validation

validation error for @pattern

烈酒焚心 提交于 2019-12-12 06:01:46
问题 Getting validation error for @NotNull @NotEmpty @Pattern(regexp ="^[0-9a-zA-Z,.\'_+*()?;\"!$%#@={}]$[\\/®™©|&-]*$") private String testListName; I am passing the testlist name in json format to create a resource using restservice. and getting validation error. {"testListName":"longlist"} 来源: https://stackoverflow.com/questions/37795395/validation-error-for-pattern

ConstraintValidatorContext stores previous nodes when it shouldn't

房东的猫 提交于 2019-12-12 05:07:07
问题 I have this class @HasNose @HasMouth public class Person { String fieldA; String fieldB; // getters and setters } Now the custom annotations validator look something like this // validator of @HasNose @Override public boolean isValid(Object object, ConstraintValidatorContext context) { // some tests that determine there is an error context.disableDefaultConstraintViolation(); context.buildConstraintViolationWithTemplate("Some message") .addNode("fieldA") .addConstraintViolation(); } and //

Hibernate Error with Custom Bean Validation

我与影子孤独终老i 提交于 2019-12-12 04:24:55
问题 I'm trying to create a custom bean validation, so I write this custom constraint: @Documented @Constraint(validatedBy = ValidPackageSizeValidator.class) @Target({ElementType.TYPE}) @Retention(RetentionPolicy.RUNTIME) public @interface ValidPackageSize { String message() default "{br.com.barracuda.constraints.ValidPackageSize}"; Class<?>[] groups() default {}; Class<? extends Payload>[] payload() default {}; } And a validator: public class ValidPackageSizeValidator implements

Spring webflow partial validation

半世苍凉 提交于 2019-12-12 04:04:43
问题 I am trying to implement partial validation in Spring Webflow 2.4. According to their reference manual the validation should be done very simply using groups: @NotNull @Size(min = 2, max = 30, groups = State1.class) private String name; In my understanding the State1 should be the ID of view-state in which the model should be validated. So the definition of this view state in flow.xml would look like this: <view-state id="state1" model="modelObject"/> I was trying to define the State1 as an

Vaadin 7 - Bean Validation

a 夏天 提交于 2019-12-12 02:59:43
问题 I have been trying out Vaadin 7. Firstly, I must admin that I am quiet a noob at Vaadin and not much familiar with JAVA persistance. I am thus trying to learn bean validation and how to use it. I have followed couple of tutorials, but its really hard to decide which is the latest and correct one for Vaadin 7. Nonetheless, I tried downloading and using the JPA container and the BeanValidator and I can't get it working. Here is the code I am using: package com.example.firstvaadin; import java

Bval ValidationMessages.properties in scala eclipse project

笑着哭i 提交于 2019-12-12 00:55:34
问题 I have a scala project (based around unfiltered and jetty) which uses bval. I've tried everything I can think of to get custom validation messages to load from a properties file, but it just doesn't work. I have a scala class like this: class AddName{ @NotEmpty(message = "{firstName.notEmpty}") var firstName: String = "" @NotEmpty(message = "{lastName.notEmpty}") var lastName: String = "" } and a ValidationMessages.properties file containing the following: firstName.notEmpty=enter a first

Where is implementation of @Future defined?

半腔热情 提交于 2019-12-12 00:21:50
问题 Java persistence & hibernate make it easy to add property-level constraints to entities. @Entity @Table(name = "party") public class PartyEntity { @Future public DateTime start; } The javax.validation.constraint.Future annotation is defined without a specific implementation. @Target({ METHOD, FIELD, ANNOTATION_TYPE, CONSTRUCTOR, PARAMETER }) @Retention(RUNTIME) @Documented @Constraint(validatedBy = {}) public @interface Future { // ... } Where is actual validation implemented? How can this be

Spring MVC - REST Webservices. Bean Validation Messages

匆匆过客 提交于 2019-12-11 19:23:56
问题 I am trying to find out the way to show proper validation messages in my Spring MVC application. This is the Example Bean: @Entity @Table(name="employees") public class Person { private Integer person_id; private String name; private String name2; private String email; private double phone; private String desc; @Id @Max(value=500) @Column (name="id") public Integer getPerson_id() { return person_id; } public void setPerson_id(Integer person_id) { this.person_id = person_id; } @NotNull

Bean Validation: Receive EntityNotFoundException though have a constraint to validate entity

跟風遠走 提交于 2019-12-11 19:19:23
问题 Technologies: Spring, Hibernate, JSR-303, JQuery Platform: Windows I am trying to implement @IdMustExist JSR-303 constraint. The purpose of the constraint is to check whether the entered id value exists in associated table. Please see this link for the IdMustExist.java and IdMustExistValidator.java code snippets. Scenario 1 - Valid Id value is entered: In this case, when hibernate's EntityManager.merge operation is executed, I see that the @IdMustExist constraint is executed. It successfully

Spring MVC Bean Validation

强颜欢笑 提交于 2019-12-11 19:16:33
问题 I have to implement validations for a web app that uses Spring MVC 3. The problem is that the bean class has methods like getProperty("name") and setProperty("name",valueObj). The validations have to be done on the data that is returned by passing different values to getProperty("name") , for eg: getProperty("age") should be greater than 16 and getProperty("state") should be required. I would like to know if there is any support for validation this kind of Bean and if not, what can be the