src/Schema.php
protected function isValidInternal(array &$data, array $schema, Validation &$validation = null, $path = '') {
        if ($validation === null) {
            $validation = new Validation();
        }

        // Loop through the schema fields and validate each one.
        foreach ($schema as $name => $field) {
            // Prepend the path the field label.
            if ($path) {
                $field['path'] = $path.array_select(['path', 'name'], $field);
            }

            if (array_key_exists($name, $data)) {
                $this->validateField($data[$name], $field, $validation);
            } elseif (val('required', $field)) {
                $validation->addError('missing_field', array_select(['path', 'name'], $field));
            }
        }

        // Validate the global validators.
        if ($path == '' && isset($this->validators['*'])) {
            foreach ($this->validators['*'] as $callback) {
                call_user_func($callback, $data, $validation);
            }
        }

        return $validation->isValid();
    }
protected function isValidInternal(array &$data, array $schema, Validation &$validation = null, $path = '') {
        if ($validation === null) {
            $validation = new Validation();
        }

        // Loop through the schema fields and validate each one.
        foreach ($schema as $name => $field) {
            // Prepend the path the field label.
            if ($path) {
                $field['path'] = $path.array_select(['path', 'name'], $field);
            }

            if (array_key_exists($name, $data)) {
                $this->validateField($data[$name], $field, $validation);
            } elseif (val('required', $field)) {
                $validation->addError('missing_field', array_select(['path', 'name'], $field));
            }
        }

        // Validate the global validators.
        if ($path == '' && isset($this->validators['*'])) {
            foreach ($this->validators['*'] as $callback) {
                call_user_func($callback, $data, $validation);
            }
        }

        return $validation->isValid();
    }
Validate data against the schema and return the result.

@param array &$data The data to validate.
@param array $schema The schema array to validate against.
@param Validation &$validation This argument will be filled with the validation result.
@param string $path The path to the current path for nested objects.
@return bool Returns true if the data is valid. False otherwise.