where is #Equals annotation in playframework 2.0? - validation

I am trying to validate the equality of password with confirmPassword field in a registration form.
I am aware that in v.1(precisely v.1.2.4), you can do this using #Equals("confirmPassword") annotation.
However the same functionality seems to be missing in v2.0.
Am I missing out on something or v2.0 doesn't implement this anymore?

Have a look at Forms Validation for Play 2.0, specifically the Constraints section. The play.data.validation.Constraints class contains several built-in validation annotations according to the documentation. They made a lot of changes between the 1.* and 2.* versions.

Related

JSR 303 vs Spring validation

I am new to Spring validation. Recently I have been exploring different approaches of validation utilities available in Spring. I found there are basically two approaches: 1. with JSR-303 and 2. by implementing Validator interface in Spring.
What I understood, with first approach one can achieve model level validation whereas the latter is more appropriate to validate String, Integer types of inputs. Is there something more, that I am missing here?
Here is an open source alternative to JSR-303.
This solution can perform all validation of the request message, but no hassle coding is required.
https://github.com/ckpoint/CheckPoint
With Check-Point, all validation is possible without further code, just by changing the annotation of the Controller method.
After that, all validation settings can be easily made in Admin Page.
I think this video can help your understand. https://youtu.be/I1aEIztXlhE
Check-Point Admin-Page Setting Screen

How to create custom BV constraint validator for a List property? [duplicate]

It seems that JSF 2.0 does not call "class level constraints". Quoting from an SO answer
JSF 2.0 doesn't call class level validation constraints. From JSF validation: JSF 2 provides built-in integration with JSR-303 constraints. When you are using bean validation in your application, JSF automatically uses the constraints for beans that are referenced by UIInput values.
The answer furthermore suggests using SeamFaces to validate the class-level constraints anyways.
Unfortunately this is a non-option, since it introduces a somewhat massive dependency for just validating what should be validated anyways.
My question thus is:
How can I get JSF to validate class-level constraints?
Manual validation in the controller is tedious and a lot of repeated code, and thus an option I would like to avoid.
I have attempted to do this by annotating the Controller-Field to be validated with #Valid, which didn't help.
I guess it should be possible to either make the "Process Validations" phase do that for me or hook in something akin to a Filter after the "Update Model Values" phase, that would centrally run the model values through a Validation.
Until the upcoming JSF 2.3, JSF doesn't support class level validation using a.o. #Valid. This is an eternal issue, given that the very first JSF spec issue ever addresses this.
Your resort is either using a 3rd party library which has already taken care of it, or homebrewing it based on sources of the open source library in question (taking licensing into account).
Apart from SeamFaces <s:validateForm> which you already found, there's also OmniFaces <o:validateBean>. The major difference as compared to <s:validateForm> is that it doesn't use a JSF Validator, but a JSR303 ConstraintValidator (and that you've the whole entity immediately at hands without the need to declare and annotate a bunch of fields, repeating the entity's properties.
JSF 2.3 support will come in flavor of <f:validateWholeBean> which is largely based on OmniFaces <o:validateBean>.

How to create a specific validator for a field's model

I want to use a specific validation for a field in my class. It should assure that the username field follow some specific rules.
Can someone point me some docs that show me how to create a validator specifically for a field in a class?
I'm using Spring framework.
Whats wrong with the spring documentation.
The page for that is usually http://docs.spring.io/spring/docs/current/spring-framework-reference/html/validation.html
There are different ways to do that. I personally prefer the javax.validation spring integration instead of the system by spring directly. The creation of a custom validator for an object can be seen in the hibernate-validator (implementation of javax.validation) https://docs.jboss.org/hibernate/validator/4.0.1/reference/en/html/validator-customconstraints.html

How can I replace Hibernate Validator with something else?

I'm not the fan of Hibernate Validator. I would like to use something else (like oval) or implement my custom validation logic. What's the best way to replace Hibernate Validator with my custom validation logic?
As Hibernate Validator (>= 4.x) is one implementation of the Bean Validation specification (javax.validation.* API) you can use other compliant implementations easily (of course depending on to which degree you're using HV specific APIs and functionality such as the provided custom constraints).
Bean Validation provides the concept of custom constraints to implement custom validation logic.
That said (I'm one of the HV committers), what is it that makes you wish to use another implementation? If you found any bugs or have feature requests, you can open a ticket in our issue tracker. If you have an idea for improvement you'd like to discuss, you can either post to our forum or the mailing list. Any feedback matters, so be sure to speak up.

Validation App Block validating NetTiers entities

Here is my question: does anyone know how to set up custom validation for NetTiers entities?
I have a NetTiers web solution that was generated with the EntLib 4.1 validation app block. The actual entities' properties are decorated with the validation attributes to ensure that the dataase integrity is maintained. What I need to do is add custom validation to the entities.
I know how to write the custom validators. I'm just not sure how to wire them up to the each entities so that I can perform custom validation. What I am looking for is an overview on how to do this.
Any help would be appreciated.
Thanks,
Joe
Are you using the latest release of .netTiers? Support for data annotations was added in this patch and committed to core.
I would take a look at the following documentation. I'm thinking that this is something that you would need to wire up programmatically. Well make sure that this scenario works in v3.

Resources