Controller_Validator_Abstract::normalizeRules PHP Method

normalizeRules() public method

In: "int|required|alphanum|save" (Basic) In: "int!|a-z|" (Advanced) Out: array('int','required','alphanum','save')
public normalizeRules ( $rules )
    public function normalizeRules($rules)
    {
        // If you want to use a pipe in a regex, custom message etc,
        // single-quote the string (escaping would be too confusing in regexes):
        //
        // This works with:
        //
        // 'foo?\'my piped | string\''
        // "foo?'my piped | string'"
        //
        // BIG NOTE: There is a reason why there are 2 formats. I don't
        // want developres to use ONLY the pipe format. There is always
        // multi-argument format, where argument can be anything, and
        // we don't complicate things and try to get around regexps
        //
        // is('name|required?my pipe|string')       // Bad
        // is('name','required?my pipe|string')     // Good
        // is('name','required?','my pipe|string')  // Best
        // TODO: clean up
        $rules = preg_split('/[|,:]/', $rules);
        $field = array_shift($rules);
        return array($field, $rules);
    }