I want to blacklist a few words and blank. But negation is not working in JPA Pattern Validator regex.
@Pattern(regexp = "^(?!(|null|na))$", message = "Invalid/Empty input")
EDIT: Looks like none of the flags working. Is it expected or am I doing something wrong?
I might be a bit late to the party yet to prevent others to struggle like I did, in my case I wanted to avoid certain suffixes, lets say -INVALID
and -UNDESIRED
, the pattern that help me with it was:
@Pattern(
regexp = "^.+?(?<!-INVALID)(?<!-UNDESIRED)$",
message = "Invalid suffix [-INVALID, -UNDESIRED]")