I have a variable name in a bean. I want to add @Pattern
validation to accept only alphanumeric.
Currently, I have this one.
@NotNull
@Pattern(regexp = "{A-Za-z0-9}*")
String name;
But the error is Invalid regular expression.
I tried [A-Za-z0-9]
. But this is not working either. No errors though. It shows any valid input as failed.