Sprig_Core::check PHP Метод

check() публичный Метод

Check the given data is valid. Only values that have editable fields will be included and checked.
public check ( array $data = NULL ) : array
$data array
Результат array filtered data
    public function check(array $data = NULL)
    {
        if ($data === NULL) {
            // Use the current data set
            $data = $this->changed();
        }
        $data = Validate::factory($data);
        foreach ($this->_fields as $name => $field) {
            if (!$data->offsetExists($name)) {
                // Do not add any rules for this field
                continue;
            }
            $data->label($name, $field->label);
            if ($field->filters) {
                $data->filters($name, $field->filters);
            }
            if ($field->rules) {
                $data->rules($name, $field->rules);
            }
            if ($field->callbacks) {
                $data->callbacks($name, $field->callbacks);
            }
        }
        if (!$data->check()) {
            throw new Validate_Exception($data);
        }
        return $data->as_array();
    }