public function isValid(array $rules, array $data) {
        $errors = [];
        foreach ($rules as $field => $fieldRules) {
            $value       = isset($data[$field]) ? $data[$field] : null;
            $fieldErrors = $this->isValidValue($fieldRules, $value);
            if (!empty($fieldErrors)) {
                $errors[$field] = $fieldErrors;
            }
        }
        return [
            'valid' => count($errors) === 0,
            'errors' => $errors
        ];
    }
public function isValid(array $rules, array $data) {
        $errors = [];
        foreach ($rules as $field => $fieldRules) {
            $value       = isset($data[$field]) ? $data[$field] : null;
            $fieldErrors = $this->isValidValue($fieldRules, $value);
            if (!empty($fieldErrors)) {
                $errors[$field] = $fieldErrors;
            }
        }
        return [
            'valid' => count($errors) === 0,
            'errors' => $errors
        ];
    }
public function isValid ( array $ rules , array $ data ) { $ errors = [ ] ; foreach ( $ rules as $ field => $ fieldRules ) { $ value = isset ( $ data [ $ field ] ) ? $ data [ $ field ] : null ; $ fieldErrors = $ this -> isValidValue ( $ fieldRules , $ value ) ; if ( ! empty ( $ fieldErrors ) ) { $ errors [ $ field ] = $ fieldErrors ; } } return [ 'valid' => count ( $ errors ) === 0 , 'errors' => $ errors ] ; }
Performs the actual validation.

@param array $rules
the validation rules: an array with a field name as key and an array
of rules to use for this field; each rule is an array with the validator
name as first element and parameters as following elements; example:
array('a' => array(array('required')), 'b' => array(array('min', 1)))
@param array $data
the data to validate as a map

@return array<string,boolean|array>
the validation result having the keys "valid" (true or false) and
the key "errors" containing all failed fields as keys with arrays of the
failed validator names; example where the field "b" from the above sample
failed due to the min validator:
array('valid' => false, errors => array('b' => array('min')))
the "or" validator doesn't return a single string on validation error;
instead, it returns an array listing all failed validators of it:
array('or' => array('url', 'email')
Performs the actual validation .