The Validator class has all kind of useful methods like Validator::boolean() as a shortcut for ->add(['field', 'name', ['rule' => 'boolean']]}). As far as I can see there is no such method for the "custom" rule that allows you to specify a custom regex. Is there a reason for this or was it merely missed? (Maybe Validator::regex might be a less confusing name.)
A more general approach might be to add a __call method to Validator that works for all the default rules automatically (just based on the name).
regex or pattern is probably a better name than custom.
馃憤 for regex() over custom() (pattern could be ... whatever, say an ICU pattern)
PR is open
Most helpful comment
馃憤 for
regex()overcustom()(pattern could be ... whatever, say an ICU pattern)