Apache Struts 2 Documentation > Home > Guides > Core Developers Guide > Annotations > StringRegexValidator Annotation |
StringRegexValidator checks that a given String field, if not empty, matches the configured regular expression.
The annotation must be applied at method level.
Parameter | Required | Default | Notes |
---|---|---|---|
message | yes | field error message | |
key | no | i18n key from language specific properties file. | |
fieldName | no | ||
shortCircuit | no | false | If this validator should be used as shortCircuit. |
type | yes | ValidatorType.FIELD | Enum value from ValidatorType. Either FIELD or SIMPLE can be used here. |
regex | yes | "." | String property. The Regular Expression for which to check a match. |
caseSensitive | no | true | Whether the matching of alpha characters in the expression should be done case-sensitively. |
@StringRegexValidator(message = "Default message", key = "i18n.key", shortCircuit = true, regex = "a regular expression", caseSensitive = true)