on-internet
← Community

Use @Pattern to validate UUID or UUID.toString()

Stack Overflow ·

As we know, @Pattern annotation can only be used for implementation of CharSequence, such as String. Thus the following validation on UUID won't work. @Pattern(regexp="^[0-9a-f]{8}-[0-9a-f]{4}-[1-5][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$") private UUID id; Is there a way to use @Pattern annotation directly on UUID or based on UUID.toString()? THE ACTUAL SCENARIO: public class IndexController { ... public ResponseEntity<Void> postIndexes(@ApiParam(value = INDEXES_DESC, required = true) @Valid @RequestBody @Size(min = 1, max = 2000) List<Index> indexes) { ... } ... } @JsonInclude(JsonInclude

Comments

Sign in or sign up to comment and upvote.

No comments yet.