i want to validate an input string with alphanumeric chars, and square brackets and hypen for example [Z01-Z02]
for this i set a validation property as
Validator.SqBrackText=^[0-9a-zA-Z \[\]\-]{1,111}$
But ESAPI.validator().getValidInput(context, input, "SqBrackText", maxLen, allowNull, true);
gives exception as in
java.lang.IllegalArgumentException: The selected type [SqBrackText] was not set via the ESAPI validation configuration
at org.owasp.esapi.reference.DefaultValidator.getValidInput(DefaultValidator.java:215)
obviously ESAPI is not accepting the validation property although regExTester accepts the rule. There are other validation property rules in this same file which ESAPI is OK with.
Can anyone suggest what may be wrong or missing in this.
thanks
Well got the solution - need to give 2 backslash to escape the []-
chars.
so used this regex and it worked OK
Validator.SqBrackText=^[0-9a-zA-Z \\[\\]\\-]{1,1024}$
thx for all the help !