Cakephp: Add Validator::custom()

Created on 25 Jan 2017  路  3Comments  路  Source: cakephp/cakephp

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).

enhancement validation

Most helpful comment

馃憤 for regex() over custom() (pattern could be ... whatever, say an ICU pattern)

All 3 comments

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

Was this page helpful?
0 / 5 - 0 ratings