dimanche 30 décembre 2018

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

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()?

Aucun commentaire:

Enregistrer un commentaire