Applies the filter to a subject.

@param array $data

@throws CsrfViolationException

@return bool
341334
public function apply(array $data)
    {
        if ($this->antiCsrf && ! $this->antiCsrf->isValid($data)) {
            throw new CsrfViolationException;
        }
        $this->fill($data);

        return $this->filter->apply($data);
    }
735773
public function setFilterData($data)
    {
        foreach ($data as $index => $config) {
            if (is_object($config)) {
                $config = get_object_vars($config);
            }
            $filter = new \Expose\Filter($config);
            $this->addFilter($filter);
        }
    }
1368519
public function validate(array $data)
    {
        $validator = $this->getValidator();
        if (!$validator->count()) {
            $method = new ReflectionMethod($this, 'validator');
            if ($method->getDeclaringClass()->getName() !== __CLASS__) {
                $validator = $this->validator();
            }
        }
        $this->_errors = $validator->errors($data);

        return count($this->_errors) === 0;
    }
164002
protected function validate(array &$data, array $fields = [], bool $filter_before_validate = true, array $skip = [])
    {
        static $validator;

        if (empty($fields)) {

            // No and no fields in scheme means no validation rules so we have nothing to du here
            if (empty($this->scheme['fields'])) {
                return $data;
            }

            // Use the fields list from existing scheme
            $fields = $this->scheme['fields'];
        }

        // Still no fields?
        if (empty($fields)) {
            return $data;
        }

        // Lets run our rules
        foreach ($data as $key => $val) {

            // Is this field inside the $skip array list?
            if (in_array($key, $skip)) {
                continue;
            }

            // Run possible filters before the validation process
            if ($filter_before_validate && !empty($fields[$key]['filter'])) {

                if (!is_array($fields[$key]['filter'])) {
                    $fields[$key]['filter'] = (array) $fields[$key]['filter'];
                }

                foreach ($fields[$key]['filter'] as $filter) {

                    $options = [];

                    if (is_array($filter)) {
                        $options = $filter[1];
                        $filter = $filter[0];
                    }

                    $result = filter_var($val, $filter, $options);

                    if ($result === false) {
                        $this->addError($key, sprintf($this->app->language->get('validator.filter'), $filter));
                    }
                    else {
                        $data[$key] = $result;
                    }
                }
            }

            if (empty($fields[$key]['validate'])) {
                continue;
            }

            if (empty($validator)) {
                $validator = new Validator();
            }

            if (!is_array($fields[$key]['validate'])) {
                $fields[$key]['validate'] = (array) $fields[$key]['validate'];
            }

            $validator->setValue($val);

            foreach ($fields[$key]['validate'] as $rule) {

                $validator->parseRule($rule);
                $validator->validate();

                if (!$validator->isValid()) {

                    $result = $validator->getResult();

                    if (is_array($result)) {
                        $result = vsprintf($this->app->language->get($result[0]), $result[1]);
                    }
                    else {
                        $result = $this->app->language->get($result);
                    }

                    $this->errors[$key][] = $result;
                }
            }
        }

        return $data;
    }
83246
public function applyData ( $data = NULL ) {
        parent::applyData( $data );
        if ($data != null) {
            self::$propData[$this->getKey()] = $this;
            self::$keyCache[$this->getClassKey()] = $this->__keyName;
            $key = $this->__keyName;
            self::$__ids[$this->getClassKey()][$this->$key] = true;
        }
    }
814163
protected function _filterData($data, array $filters)
    {
        $limit = false;
        if (isset($filters['limit'])) {
            $limit = $filters['limit'];
            unset($filters['limit']);
        }

        $filteredData = parent::_filterData($data, $filters);

        if ($limit) {
            if (is_array($limit)) {
                $filteredData = array_slice($filteredData, $limit[1], $limit[0]);
            } elseif (is_numeric($limit)) {
                $filteredData = array_slice($filteredData, 0, $limit);
            }
        }

        return $filteredData;
    }
556298
public function create(array $data, $skipCsrfCheck = true)
    {
        $class  = $this->getMapper()->getEntityClass();
        $entity = new $class;
        $form   = $this->getAddForm();

        if ($skipCsrfCheck) {
            $form->remove('csrf');
        }

        $form->bind($entity);
        $form->setData($data);

        if (!$form->isValid()) {
            return false;
        }

        //$this->getEventManager()->trigger(__FUNCTION__, $this, array('entity' => $entity, 'form' => $form));
        $this->getMapper()->save($entity);
        //$this->getEventManager()->trigger(__FUNCTION__.'.post', $this, array('entity' => $entity, 'form' => $form));

        $this->updateFromNode($entity);

        return $entity;
    }
870635
public function FilterSchema($Data) {
      $Fields = $this->Schema->Fields($this->Name);

      $Result = array_intersect_key($Data, $Fields);
      return $Result;
   }
1367679
protected function &loadFilterData(&$data) {

        if ( empty($this->filterMap) ) {
            return $data;
        }
        $error = null;
        $data = Filter::loadFromModel($data, $this->filterMap, $error);

        if ( $data == false ) {
            WebApplication::getInstance()->getAppError()->setCode(1);
            WebApplication::getInstance()->getAppError()->setMessage($error);
        }
        return $data;
    }
1213855
public function validate(array $data = null)
    {
        $data = $data ?: $this->getInput();

        $this->validation = $this->validator->make($data, $this->rules(), $this->messages());

        if ($this->validation->fails())
        {
            $this->failed();

            return false;
        }

        return true;
    }
1229219
public function filter($data)
    {
        // Get filter rules
        $filters = $this->filters();

        // Filter process with setting check
        if (!empty($filters) && is_array($filters)) {
            
            foreach ($filters as $key => $filter) { 
                
                if (!isset($filter[0]))
                    throw new Exception("No attributes defined in \$filters from " . get_called_class() . " (" . __CLASS__ . ")", 500);

                if (!isset($filter[1]))
                    throw new Exception("No function defined in \$filters from " . get_called_class() . " (" . __CLASS__ . ")", 500);

                list($attributes, $function) = $filter;

                $attributes = (is_array($attributes)) ? $attributes : [$attributes];

                // Filter each attribute
                foreach ($attributes as $key => $attribute) {

                    if (!isset($data[$attribute]))
                        continue;
                    
                    $data[$attribute] = call_user_func($function, $data[$attribute]);
                }
            }
        }
        
        return $data;
    }
1152954
public function is_valid(array $data) {

		$this->data = $this->apply_filters($data);

		$this->errors = $this->test_rules();

		return empty($this->errors);

	}
416585
protected final function validateNewData(array $data = null) {
		if ($data === null && isset($this->_formData)) {
			$data = $this->_formData;
		}
		if ($this->rules) {
			return $this->validateData($this->rules, $data);
		}

		return true;
	}
1246460
public function setCookie($data = [])
    {
        $controller = $this->_registry->getController();
        if (empty($data)) {
            $data = $controller->request->data;
        }
        if (empty($data)) {
            $data = $controller->Auth->user();
        }
        if (empty($data)) {
            return false;
        }

        $fields = $this->config('fields');
        $cookieKey = $this->config('cookieKey');

        foreach ($fields as $field) {
            if (isset($data[$field]) && ! empty($data[$field])) {
                $this->Cookie->write("$cookieKey.$field", $data[$field]);
            }
        }

        return true;
    }
223132
public function checkResponseIntegrity(array $data)
    {
        if (!isset($data['signature'])) {
            return false;
        }

        return $data['vads_site_id'] === (string)$this->config['site_id']
            && $data['vads_ctx_mode'] === (string)$this->config['ctx_mode']
            && $data['signature'] === $this->generateSignature($data);
    }
205743
public function validate( array $data ) {
		// Validate use Validator.
		try {
			$this->validate_use_validator( $data, $this->get_validate_rules() );
		} catch ( \Exception $e ) {
			trigger_error( $e->getMessage(), E_USER_WARNING ); // @WPCS: XSS OK.
		}

		// Validate use custom callback.
		$callbacks = $this->fields->pluck( 'validate_cb', 'id' )->filter( 'is_callable' );

		if ( $callbacks->isNotEmpty() ) {
			$this->validate_by_callbacks( $data, $callbacks->all() );
		}
	}
404855
public function sendData($data)
    {
        if (is_array($data) && count($data)) {
            $class = $this->getResponseClass();

            return $this->response = new $class($this, $data);
        }

        return false;
    }