Skip to content

Support JSR 303 validation groups #31

@hagis

Description

@hagis

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?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions