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
        ];
    }