Skip to content
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

Support JSR 303 validation groups #31

Open
hagis opened this issue Sep 21, 2016 · 4 comments
Open

Support JSR 303 validation groups #31

hagis opened this issue Sep 21, 2016 · 4 comments

Comments

@hagis
Copy link

hagis commented Sep 21, 2016

We need to validate an object of class A differently in different situations, and we use validation groups for that in the backend.

Now we would like to use valdr in the frontend, but there is no support for validation groups.

We are planning to implement support for validation groups in our own copy of valdr-bean-validation, but would ultimately like to see that feature pulled into valdr-bean-validation.

Our rough plan is as follows:

  1. Add a new config parameter "includeValidationGroups" default false.
  2. When that is enabled, add any groups defined in the bean constraint annotations into the generated JSON:
"Plan": {
  "name": {
    "size": {
      "min": 2,
      "message": "{javax.validation.constraints.Size.message}",
      "max": 255,
      "groups": [
        "ValidationGroup.Active.class"
      ]
    }
  }
}

My question is: would you consider a PR on this feature? If so, is the above approach ok?

@marcelstoer
Copy link
Collaborator

Sure, sounds reasonable.

The validation group name is just a string but I wouldn't include the .class suffix anyway. For the valdr JSON groups must be an optional attribute as I'm not sure how the .Net backend could support that.

@hagis
Copy link
Author

hagis commented Sep 22, 2016

Great! Will have a go at this. It might take several weeks calendar time depending on our backlog prioritization.

@hagis
Copy link
Author

hagis commented Nov 21, 2016

In our project we are currently using versions of valdr-bean-validation and valdr frontend containing this modification.

I would appreciate if you took the time to look into merging these PRs, as we would like to get back to using the off the shelf valdr.

@marcelstoer
Copy link
Collaborator

Your bump was due, Tero, I agree. Last night I made a mental note to talk to the valdr maintainers to analyze your PR. Once that one is approved I'll merge the Java support as well.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants