This forum has moved to a new location and is in read-only mode. Please visit talk.octobercms.com to access the new location.

Simon Shine
Simon Shine

I've got a form field that is either 4, 8 or 12. Naively I'd validate this with Validator::make($data, [..., 'field' => 'required|regex:4|8|12']), but this is syntactically ambiguous and fails.

Neither 'required|regex:(4|8|12)' nor 'required|regex:/4|8|12/' seem to work. I'm not bent on using a regular expression, but I can't find other validators that allow specific options.

Last updated

Andrey Palamarchuk
Andrey Palamarchuk

https://octobercms.com/docs/services/validation#rule-regex From notes section: When using the regex pattern, it may be necessary to specify rules in an array instead of using pipe delimiters, especially if the regular expression contains a pipe character.

1-2 of 2

You cannot edit posts or make replies: the forum has moved to talk.octobercms.com.