public function rule_regex($a)
    {
        $opt = array();
        $rule = $this->pullRule();
        if ($rule[0] != '/') {
            $rule = '/^'.$rule.'*$/';
        }
        $opt['regexp'] = $rule;

        if (!filter_var($a, FILTER_VALIDATE_REGEXP, ['options' => $opt])) {
            return $this->fail('does not match the pattern');
        }
    }
public function rule_regex($a)
    {
        $opt = array();
        $rule = $this->pullRule();
        if ($rule[0] != '/') {
            $rule = '/^'.$rule.'*$/';
        }
        $opt['regexp'] = $rule;

        if (!filter_var($a, FILTER_VALIDATE_REGEXP, ['options' => $opt])) {
            return $this->fail('does not match the pattern');
        }
    }
public function rule_regex ( $ a ) { $ opt = array ( ) ; $ rule = $ this -> pullRule ( ) ; if ( $ rule [ 0 ] != '/' ) { $ rule = '/^' . $ rule . '*$/' ; } $ opt [ 'regexp' ] = $ rule ; if ( ! filter_var ( $ a , FILTER_VALIDATE_REGEXP , [ 'options' => $ opt ] ) ) { return $ this -> fail ( 'does not match the pattern' ) ; } }
Requires a regex pattern as the
next rule in the chain.

Please give your rule a custom error message.
Requires a regex pattern as the next rule in the chain .