Skip to content

Spin off validation logic to separate repository #106

Open

Description

@pvdbosch

As was mentioned in belgif/rest-guide#169, there are some concerns of combining the validation logic of (business) values with the problem library.

I'd suggest to spin this off to a separate project because:

  • the lifecycle of validation library depends on evolution of business types, not only on technical REST API concerns
  • it allows to work towards consolidation with smalsutils-validation
    • we can work on resolving differences while keeping rest-problem-java stable
    • it's very hard to document that a (documented) module of rest-problem-java shouldn't be used in Smals

Some differences with the smalsutils-validation library:

  • Smals library uses Bean Validation, also usable outside of a REST context
  • Java implementation is kept in sync with validation logic in another Angular validation library
  • there are some other validations (like VatNumber country-specific formats), probably some divergent ones as well
  • translations of validation errors (useful when library is used in UIs)

Ideally, we could have a single validation logic for Java and integrate with different ways of using it (programmatic validation, bean validation, inside or outside a REST API context, ...)

Activity

  1. jpraet commented on Sep 26, 2024

    @jpraet
    Contributor

    Where do you see InputValidationIssues.java fit in? In the problem library or in the validation library?

  2. pvdbosch commented on Sep 26, 2024

    @pvdbosch
    ContributorAuthor

    Good point, I'd put at least the standardized business-agnostic issue types in rest-problem-java (like referencedResourceNotFound).

    Not sure about the business-specific ones (like replacedSsin and canceledSsin). It's a bit the same discussion about whether they should be included in the REST guide. Maybe best in the validation library where they can evolve with the validations themselves. Then again, they might be reusable by other validation libraries as well, but that's probably a rather theoretical advantage.

  3. jpraet commented on Oct 2, 2024

    @jpraet
    Contributor

    There was some earlier discussion about overlap between belgif-rest-problem-validator and SmalsValidation library in #16.

    I also wonder, in your current REST APIs using the SmalsValidation library: how do you map the Bean Validation exception to a BadRequestProblem? Are they mapped to urn:problem-type:belgif:input-validation:schemaViolation?

  4. pvdbosch commented on Oct 2, 2024

    @pvdbosch
    ContributorAuthor

    Seems to differ across APIs, I haven't found a common implementation for our Spring projects.

    For JAX-RS, there is a lib in use that:

    • maps bean validation exceptions from annotations in javax package to schemaViolation. These javax annations are usually generated from the OpenAPI document
    • the issue type is not set for custom bean validation annotations (other package names)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

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