bean-validation

GWT 2.4: “An internal compiler exception occurred” in project that uses Hibernate for Bean Validation

故事扮演 提交于 2019-12-08 05:42:23
问题 It's been about 5 hrs since I decided to use JSR 303 Bean Validation in my GWT project and I gotta say I can't even express (politely) how deeply unsatisfied I am with lame documentation on the subject on Google's website. I really hope you guys can help me. I followed this blog post to add client-side bean validation to my project. Unfortunately it worked only once and threw an exception in runtime saying that I need to add Hibernate Validation sources to class path. I fixed that and decided

EJB injection fails in custom ConstraintValidator on JPA persist

偶尔善良 提交于 2019-12-08 02:01:49
问题 I have a problem with my JSF/JPA/Bean Validation app. Custom constraints annotating (JPA) entity fields don’t function correctly on JPA pre-persist although they work fine during JSF form validation Environment: NetBeans IDE 8.0.2 / GlassFish Server 4.1 JPA 2.1/EJB 3.2 /CDI 1.1/BeanValidation 1.1 /Hibernate Validator 5.0.0.Final cdi-api.jar added to ejb/web projects as it seems it was missing. Problem My App contains a JSF 2.2 page whose backing/CDI bean (Register) contains references to

JSR 303 Validation with Spring (MVC) on WebSphere

我怕爱的太早我们不能终老 提交于 2019-12-07 20:38:38
问题 I'm trying to do JSR 303 bean validation with a Spring MVC Controller in WAS 8.5.5.12 Full Profile. I'm validating just a single @RequestParam, not a full bean: @RequestMapping(method=RequestMethod.GET) public String initializeCheckIn( @Valid @Pattern(regexp = "^[\\p{Alnum}]*$") @RequestParam("officeid") String officeId, HttpSession session, Model model) { Before I added some Spring-specific configuration, no validation was occurring, but neither were any errors. Presumably, the validation

hibernate validator without using autowire

扶醉桌前 提交于 2019-12-07 17:38:29
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 in the ConstraintValidator class which needs to be injected. are there side effects of using it? Is

Custom validation message for bean validation

走远了吗. 提交于 2019-12-07 16:54:02
问题 I'm creating a JSF 2-application and I'm trying to use form validation in the bean instead of the faces-page. I'd also like to use a .properties file to store the messages. I looked at this question but I don't think I have the properties-file set up correctly. Let's say I have a bean called User in a package called 'dev': @ManagedBean @SessionScoped public class User implements Serializable { @Pattern(pattern=".+@.+\\.[a-z]+", message="{dev.User.emailAddress}") private String emailAddress; /

JSR303 Validation Group inheritance

倾然丶 夕夏残阳落幕 提交于 2019-12-07 16:51:50
问题 Given the following classes and interfaces class A{ @NotNull(groups=Section1.class) private String myString } interface All{} interface Section1 extends All {} When calling A a = new A(); validator.validate(a,All.class); I would expect that it should be invalid since myString is null and it's notNull group extends All but it does not. Note that i'm using the Hibernate impl (4.0.2.GA) of the validator 回答1: Your expectations are backwards from what the specification requires. From the spec

Validating Date - Bean validation annotation - With a specific format

爱⌒轻易说出口 提交于 2019-12-07 16:02:01
问题 I would like to validate a Date for the format YYYY-MM-DD_hh:mm:ss @Past //validates for a date that is present or past. But what are the formats it accepts If thats not possible, I would like to use @Pattern . But what is the regex for the above format to use in @Pattern ? 回答1: @Past supports only Date and Calendar but not Strings, so there is no notion of a date format. You could create a custom constraint such as @DateFormat which ensures that a given string adheres to a given date format,

JSR303 - Apply all validation-groups defined in sequence

六月ゝ 毕业季﹏ 提交于 2019-12-07 12:19:08
问题 I've got a bean I'd like to do conditional validation on. For this purpose, I've defined a DefaultGroupSequenceProvider<MyObject> which returns the list of groups to validate against. Now, when validating an object that violates the constraints in more than one group in the sequence, only the first group with failures return it's result. I'd like to get an error on all violations, not just the ones in the first group with failures. I'm thinking that this doesn't need a code-sample, but if I'm

Does Spring Boot automatically resolve message keys in javax and hibernate validation annotations

懵懂的女人 提交于 2019-12-07 11:43:42
问题 I was writing a Spring Boot Application. I wanted to know does Spring Boot automatically resolve message keys in javax and hibernate validation annotations. For example: @NotEmpty(message = "${message.key}") String name; I have provided @PropertySource in my application with message properties file and file is also in my classpath. The keys are resolving with @Value but they are not being resolved in validation annotations. What could be the reason for this? Do I need configure a message

springmvc jsr303 validator co-exist with spring WebDataBinder validator in one action

北城以北 提交于 2019-12-07 04:20:23
问题 Since springmvc 3.x now supports jsr303 and old spring style validator, i want to mix them in my sample apps. But there is only one method enabled for a specified controller, is that the limit of spring framework or JSR standard? Here is my sample code. User.java, stands for the domain model, uses JSR303 for validation. public class User{ @Size(max = 16, message = "user loginId max-length is 16") private String loginId; //omit getter and setter } UserValidator.java, implements the org