spring-projects / spring-projects/spring-hateoas

Add JSR-303 support to HAL-FORMS

Open
#619 0 comments 1 reaction 0 assignees View on GitHub

Nobody has claimed this yet.

type: enhancement
Dominant language
Java
Stars
1.1k
Forks
476
PR merge metrics
No merged PRs in 30d

Description

When a Spring MVC method is marked up with:

  • @Pattern annotation - populate any HAL-FORMS model regexp attribute accordingly.
  • @NotNull annotation - flip required flags to true

This solution should certainly test derivative annotations as well, to ensure it's not just immediate.

@NotNull
@Pattern(regexp = "my pattern")
public @interface MyCustomAnnotation {
}

Such an annotation on a Spring MVC method should apply both of the patterns to the affordance.

Also note that JSR-303 supports patterns like this:

@Pattern.List( {
    @Pattern(regexp="[A-Z0-9._%+-]+@[A-Z0-9.-]+\.[A-Z]{2,4}"), //email
    @Pattern(regexp=".*?emmanuel.*?") //emmanuel
} )

HAL-FORMS should ALSO handle this scenario by having a list-based way of showing the user what the pattern is. The spec says regex is a string, so consider a stringified JSON object structure so the list of patterns is consumable by a JavaScript frontend.

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

No files or tests are named. Start by locating the Spring MVC HAL-FORMS affordance processing and existing handling for required and regex attributes; then trace how composed annotations and @Pattern.List are represented. Done means direct and derivative JSR-303 annotations are reflected in affordances, including a consumable representation for multiple patterns.

Written by the indexing model from the issue text.

Assessment

Tech stack
java, spring
Domain
api, backend-api-design
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.