public function addRule($field, $rule, $message, $options = array()) {
        if (empty($this->_fields[$field])) {
            throw new InvalidArgumentException(sprintf('Field %s does not exist', $field));
        }

        if (isset($this->_messages[$rule])) {
            $message = $message ?: $this->_messages[$rule];
        } else {
            $this->_messages[$rule] = $message;
        }

        $this->_rules[$field][$rule] = array(
            'message' => $message,
            'options' => (array) $options
        );

        return $this;
    }
public function addRule($field, $rule, $message, $options = array()) {
        if (empty($this->_fields[$field])) {
            throw new InvalidArgumentException(sprintf('Field %s does not exist', $field));
        }

        if (isset($this->_messages[$rule])) {
            $message = $message ?: $this->_messages[$rule];
        } else {
            $this->_messages[$rule] = $message;
        }

        $this->_rules[$field][$rule] = array(
            'message' => $message,
            'options' => (array) $options
        );

        return $this;
    }
public function addRule ( $ field , $ rule , $ message , $ options = array ( ) ) { if ( empty ( $ this -> _fields [ $ field ] ) ) { throw new InvalidArgumentException ( sprintf ( 'Field %s does not exist' , $ field ) ) ; } if ( isset ( $ this -> _messages [ $ rule ] ) ) { $ message = $ message ? : $ this -> _messages [ $ rule ] ; } else { $ this -> _messages [ $ rule ] = $ message ; } $ this -> _rules [ $ field ] [ $ rule ] = array ( 'message' => $ message , 'options' => ( array ) $ options ) ; return $ this ; }
Add a validation rule to a field. Can supply an optional error message and options.

@param string $field
@param string $rule
@param string $message
@param array $options
@return $this
@throws \Titon\Utility\Exception\InvalidArgumentException
Add a validation rule to a field . Can supply an optional error message and options .