-
Notifications
You must be signed in to change notification settings - Fork 21
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Could be able to avoid business validation? #11
Comments
Not sure I understand this feature request. Only the supported annotations and the configured custom annotations are processed. It's our assumption that all validations in this set should also be applied in the front-end. Do you disagree? |
I defined a User entity. The entity defines multiples attributes. Some (login, password, firstName, lastName, email) must be validated at the front-end level and others (authorities, persistentTokens) should be validated at the backend level. I am looking a way to avoid the servlet to send backend rules to the front-end
|
Hmm, still don't get it... Neither
In fact, they don't have Bean Validation annotations at all. When you request
are you implicitly saying that the current version of the valdr Bean Validation returns annotations place on either of the two fields? |
Yes the servlet returns rules because the Authority and the PersistentToken classes are two entities which contain JSR-303 annotations even if there is no Bean Validation annotations |
Ok, I'm beginning to see the issue. |
I am looking to see if I will add your project as a standard stack in JHipster (http://jhipster.github.io/) You can use the JHipster sample as example (https://github.com/jhipster/jhipster-sample-app) pom.xml (Add a new dependency)
bower.js (Add a new dependency)
src/main/java/com/mycompany/myapp/config/WebConfigurer.java (Initialize the ValidationRules Servlet)
Let me know if you need more information. |
I just integrated valdr in JHipster to test this. The problem is that hsr303Servlet.setInitParameter("modelPackages", "com.mycompany.myapp.domain"); Therefore you end up with a validation rules JSON that contains those two classes as they are considered part of your domain model AND have JSR303-annotated fields. If you don't want those classes to be part of the JSON returned to the client, just move them to another package. This would fix the issue for your case, but it would probably still make sense to be able to exclude classes that are in the We will discuss this and update the issue. |
Also, keep in mind that the If we decide to support exclusion in any form I'd propose the following:
However, I still dither whether we really need this:
@philippd what's your take on this? |
I think that excluding classes and fields is a feature that we should support. It may well be that you have domain objects that you don't want publicly known for whatever reason. Even if it's only to keep the JSON structure small for performance reasons... On field level we should probably also support ignoring fields which are annotated with
Yep, that's fine if you agree with the above. |
The support of |
@jmirc exclusion of classes and fields is part of v1.1 which was released a few days ago. |
I've found my problem, sorry for that... I'm working with angular 1.2.x not 1.3 and Firefox provide a better error log |
The validationRules json contains front-end and business rules. For example I have a User JPA which contains some contraints related to spring security tokens. These contraints are used by the backend but not at the front-end level.
It could be great to be able to avoid specific contraints from the validationRules.
The text was updated successfully, but these errors were encountered: