Skip to content

Add JSR-303 support to HAL-FORMS #619

Open
@gregturn

Description

@gregturn

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.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions