-
Notifications
You must be signed in to change notification settings - Fork 129
Description
Custom add-on, wants to validate uk style postal code via regex validation. rules:
'required|regex[/^[A-Z]{1,2}\d[A-Z\d]??\d[A-Z]{2}$/i]'
The regex works to match outside of EE, but doesn't in EE. After much research, the issue is that regex is getting split on the comma in {1,2}
I ended up logging a php error:
preg_match(): No ending delimiter ‘/’ found /Users/robinsowell/Sites/74/system/ee/ExpressionEngine/Service/Validation/Rule/Regex.php 24
Because the preg_match was using /^[A-Z]{1 as the regex. Because the full expression got exploded on the comma.
User tracked this down to “system/ee/ExpressionEngine/Service/Validation/Validator.php:301”
$parameters = explode(',', $parameters);
Which we need for enum, etc. but it jams that regex. May need a special case for $rule_name === “regex”, but it's thick enough in there I'd prefer not to make the change myself.