hibernate-validator

How to solve NoSuchMethodError for javax.validation when deploying a spring boot application in weblogic server?

◇◆丶佛笑我妖孽 提交于 2019-12-05 02:23:24
问题 I am trying to deploy a simple spring boot application that will expose some rest api and I use hibernate entity manager to manipulate entity objects. When I try to deploy this application to Oracle Weblogic 12c, I get the following exception: <Jan 11, 2016 6:20:14 PM BDT> <Error> <Console> <BEA-240003> <Administration Console encountered the following error: weblogic.application.ModuleException: java.lang.NoSuchMethodError: javax.validation.spi.ConfigurationState.getParameterNameProvider(

How would I specify a Hibernate “@Pattern” annotation using a regular expression from a .properties file or database

孤街浪徒 提交于 2019-12-04 23:35:37
问题 Situation : I would like to perform Hibernate Validation based upon user properties (to allow different validation rules for input based upon a user's account data) - I think it must be possible to use a .properties file to specify a particular regular expression, but I can't figure out what is wrong: My current method of specifying a validation regex pulls that regex from a constant in a particular interface file (to keep everything together) and plugs it in as a constant in an @Pattern()

How to validate number string as digit with hibernate?

限于喜欢 提交于 2019-12-04 23:10:50
Which annotations would I have to use for Hibernate Validation to validate a String to apply to the following: //should always have trimmed length = 6, only digits, only positive number @NotEmpty @Size(min = 6, max = 6) public String getNumber { return number.trim(); } How can I apply digit validation? Would I just use @Digits(fraction = 0, integer = 6) here? You could replace all your constraints with a single @Pattern(regexp="[\\d]{6}") . This would imply a string of length six where each character is a digit. You can also create your own hibernate validation annotation. In the example below

Adding custom error messages for validation in Spring-MVC

这一生的挚爱 提交于 2019-12-04 21:08:02
I am using Spring-MVC and I would like to do validation tests in backend. Currently I am able to perform the tests, redirect properly to the link. But I am only unable to add custom error messages incase there is a problem, Example : "Firstname is empty". I tried using the ValidationMessages_en_EN.properties file in WEB-INF, but that also didn't help. I am posting my code, kindly let me know where I am going wrong : COntroller : @Controller public class PersonController { @RequestMapping(value = "/", method = RequestMethod.GET) public String listPersons(Model model) { Person person =

f:convertNumber on Double: ClassCastException

廉价感情. 提交于 2019-12-04 20:39:05
In JSF 2.3, I have an h:inputText to edit a Double value, which has in addition Bean-Validation constraints. The h:inputText has a f:convertNumber . When submitting the form, this leads to a ClassCastException (see below). So, it seems, that f:convertNumber produces a Long which then, could not be converted to Double to validate the @DecimalMin constraint, right? In JSF 2.2 this worked as expected, the problem occured after upgrading to JSF 2.3. Does anybody has any ideas what could be the problem? I could reproduce this in WildFly 15.0.1 with the following minimal example with just one

Hibernate Validator. How to work with @Valid annotation?

 ̄綄美尐妖づ 提交于 2019-12-04 20:32:11
问题 What purpose of @Valid annotation when putting it on method parameter level? public void (@Valid Person p) { ... } I created a test, and passed to this method non-valid object, but nothing happens. I expect to get an exception. 回答1: The @ Valid annotation on an object is an indication to the validation framework to process the annotated object. When used on a parameter of a method this is referred to as method level validation . Note that method level validation is not part of the core

Disabling hibernate validation annotations dynamically at runtime?

谁说我不能喝 提交于 2019-12-04 19:35:53
Is it possible to turn off certain constraints / annotations per class at runtime? For instance if I wanted to turn of a @NotNull check on a firstName field, is that possible? This would make testing to see whether a certain constraint is triggered correctly simpler, as I could turn off all the other constraints, and just check that one constraint. Is it possible to turn off certain constraints / annotations per class at runtime? For instance if I wanted to turn of a @NotNull check on a firstName field, is that possible? No it is not. Bean Validation does not define such a feature. There is an

Message parameters not resolved in localized Spring Boot validation messages

痴心易碎 提交于 2019-12-04 19:00:34
I am building a project using Spring Boot 2.1.8 , I have spring-boot-starter-web in my POM and I can see Maven pulling hibernate-validator 6.0.17 onto the classpath. I have my messages in the resource folder and they appear to be looked up correctly so that when I change the locale Spring loads the message from the correct file. The relevant method in my @RestController takes a @Valid and @RequestBody annotated DTO. It triggers the ResponseEntityExceptionHandler#handleMethodArgumentNotValid() to fire in my controller advice when the DTO fails validation. My DTO has a field annotated in the

Syntactically incorrect request sent upon submitting form with invalid data in Spring MVC (which uses hibernate Validator)

情到浓时终转凉″ 提交于 2019-12-04 14:01:38
问题 Login form: <f:form class="form-horizontal" method="post" action="/login" commandName="logindata"> <fieldset> <legend class="text-info">Login</legend> <div class="control-group"> <f:label path="uname" class="control-label" for="uname">Username</f:label> <div class="controls"> <f:input type="text" path="uname" name="uname" id="uname" placeholder="Username" /> </div> </div> <div class="control-group"> <f:label path="pwd" class="control-label" for="pwd">Password</f:label> <div class="controls">

How to Validate different model class into one form using Spring MVC JSR-303 Validator

Deadly 提交于 2019-12-04 13:11:25
I have form inside jsp page as below: <springForm:form action="${addAction}" name="frm" method="post" commandName="employee"> <table> <tr> <td><label>First Name</label> </td> <td><springForm:input path="firstName" /></td> <td><springForm:errors path="firstName" cssClass="error" /></td> </tr> <tr> <td><label>Last Name</label></td> <td><springForm:input path="lastName" /></td> <td><springForm:errors path="lastName" cssClass="error" /></td> </tr> <tr> <td><label>Email</label> </td> <td><springForm:input path="email" /></td> <td><springForm:errors path="email" cssClass="error" /></td> </tr> <tr>