Validator function for the "pattern" constraint.