Validates the filter data

@return boolean
489405
public function validate()
    {
        $this->validator = Validator::make($this->getAttributes(), $this->getRules());

        return ! $this->validator->fails();
    }
1062763
protected function validateSubtractProduct()
    {
        $field = 'subtract';
        $value = $this->getSubmitted($field);

        if (isset($value)) {
            $this->setSubmitted($field, filter_var($value, FILTER_VALIDATE_BOOLEAN));
        }

        return true;
    }
162782
public function isValid()
    {
        // these schemes are allowed
        $allowedSchemes = $this->getAllowedSchemes();

        // get the field value
        $url = $this->field->getValue();


        // not required and empty? Then its valid
        if ($this->isNotRequiredAndEmpty($url)) {
            return true;
        }

        if ($this->getMaxLength() && strlen($url) > $this->getMaxLength()) {
            // Over maximum length.
            return false;
        }

        // do simple validation
        if (!filter_var($url, FILTER_VALIDATE_URL, FILTER_FLAG_HOST_REQUIRED | FILTER_FLAG_SCHEME_REQUIRED)) {
            return false;
        }

        // check if we have a tld
        if (!$this->isSkipTldCheck() && !preg_match('#\.[a-z]{2,}$#', parse_url($url, PHP_URL_HOST))) {
            return false;
        }

        // further validation is required.
        if (in_array(parse_url($url, PHP_URL_SCHEME), $allowedSchemes)) {
            return true;
        }

        return false;
    }
1082717
public function doValidate()
    {
        $value = $this->valRaw();
        $dateArray = $this->getDateArray($value);
        $isValid = !empty($dateArray) && \checkdate((int) $dateArray['mon'], (int) $dateArray['mday'], (int) $dateArray['year']);
        return $isValid;
    }
533835
public function isValid($context = null)
    {
        // When there's an invalid data type, it should immediately report as invalid.
        if ($this->invalidDataTypeException !== null) {
            return false;
        }

        // When there's no data and the filter itself is not required,
        // it should immediately report as valid.
        if (!$this->data && !$this->isRequired()) {
            return true;
        }

        // Don't filter at all when "inputsToFilter" is set to empty array
        if (!$this->needsFiltering()) {
            return true;
        }

        return parent::isValid($context);
    }
420689
private function validate()
    {
        if (!$this->cfg['validate']) {
            return true;
        }
        $formIsValid = true;
        foreach ($this->currentFields as $field) {
            $isValid = $field->validate();
            $formIsValid = $formIsValid && $isValid;
        }
        return $formIsValid;
    }
335134
final public function validate(): bool
    {
        // validate csrf token if required
        if ($this->_tokenRequired && !$this->_tokenOk) {
            App::$Session->getFlashBag()->add('warning', __('Hack attention: security token is wrong!'));
            return false;
        }
        // get all rules as array from method rules()
        $rules = $this->rules();
        // get default values of attributes
        $defaultAttr = $this->getAllProperties();

        // start validation: on this step class attribute values will be changed to input data if it valid
        $success = $this->runValidate($rules);

        // get not-passed validation fields as array
        $badAttributes = $this->getBadAttributes();
        // prevent warnings
        if (Any::isArray($badAttributes) && count($badAttributes) > 0) {
            foreach ($badAttributes as $attr) {
                if (Str::contains('.', $attr)) { // sounds like dot-separated array attr
                    $attrName = strstr($attr, '.', true); // get attr name
                    $attrArray = trim(strstr($attr, '.'), '.'); // get dot-based array path

                    $defaultValue = new DotData($defaultAttr); // load default attr

                    $dotData = new DotData($this->{$attrName}); // load local attr variable
                    $dotData->set($attrArray, $defaultValue->get($attr)); // set to local prop. variable default value

                    $this->{$attrName} = $dotData->export(); // export to model
                } else {
                    $this->{$attr} = $defaultAttr[$attr]; // just set ;)
                }
                // add message about wrong attribute to session holder, later display it
                $attrLabel = $attr;
                if ($this->getLabel($attr) !== null) {
                    $attrLabel = $this->getLabel($attr);
                }

                App::$Session->getFlashBag()->add('warning', __('Field "%field%" is incorrect', ['field' => $attrLabel]));
            }
        }

        return $success;
    }
792511
public static function validateFloat($data, callable $filter=null) {
        if ( is_float($data) === false ) return false;
        return self::applyFilter($data, $filter);
    }
222468
public function isValid() : bool
    {
        if (false === $this->validated) {
            $this->validate();
        }
        return (count($this->validation_errors) === 0);
    }
1149164
public function validate()
    {
        $validatorFactory = new Factory(new Translator(new ArrayLoader(), 'en'), new Container());
        $validator = $validatorFactory->make($this->attributes, static::$rules);

        if ($validator->passes()) {
            return true;
        }

        $this->setErrors($validator->messages());

        return false;
    }
293731
protected function validateFilters(/** @noinspection PhpUnusedParameterInspection */
        &$document_data, &$data, array $data_pointer, array $parent_data_pointer, ISchema $document, $schema, ValidationResult $bag): bool
    {
        if (!property_exists($schema, Schema::FILTERS_PROP) || !$this->filters) {
            return true;
        }

        /** @var array $filters */
        $filters = null;
        if (is_string($schema->{Schema::FILTERS_PROP})) {
            $filters = [(object)[Schema::FUNC_NAME => $schema->{Schema::FILTERS_PROP}]];
        }
        elseif (is_object($schema->{Schema::FILTERS_PROP})) {
            $filters = [$schema->{Schema::FILTERS_PROP}];
        } elseif (is_array($schema->{Schema::FILTERS_PROP})) {
            $filters = $schema->{Schema::FILTERS_PROP};
            if (count($filters) === 0) {
                return true;
            }
            foreach ($filters as &$filter) {
                if (is_string($filter)) {
                    $filter = (object)[Schema::FUNC_NAME => $filter];
                }
            }
            unset($filter);
        } else {
            throw new SchemaKeywordException(
                $schema,
                Schema::FILTERS_PROP,
                $schema->{Schema::FILTERS_PROP},
                "'" . Schema::FILTERS_PROP . "' keyword must be a string, an object or an array of objects, " . gettype($schema->{Schema::FILTERS_PROP}) . " given"
            );
        }

        $type = $this->helper->type($data, true);
        $filter_name = null;
        $valid = true;
        foreach ($filters as $filter) {
            if (!is_object($filter)) {
                throw new SchemaKeywordException(
                    $schema,
                    Schema::FILTERS_PROP,
                    $schema->{Schema::FILTERS_PROP},
                    "'" . Schema::FILTERS_PROP . "' keyword must be a string, an object or an array of objects, found " . gettype($filter)
                );
            }
            if (!property_exists($filter, Schema::FUNC_NAME)) {
                throw new SchemaKeywordException(
                    $filter,
                    Schema::FUNC_NAME,
                    null,
                    "'" . Schema::FUNC_NAME . "' keyword is required"
                );
            }
            if (!is_string($filter->{Schema::FUNC_NAME})) {
                throw new SchemaKeywordException(
                    $filter,
                    Schema::FUNC_NAME,
                    $filter->{Schema::FUNC_NAME},
                    "'" . Schema::FUNC_NAME . "' keyword must be a string, " . gettype($filter->{Schema::FUNC_NAME}) . " given"
                );
            }

            $filterObj = $this->filters->get($type, $filter->{Schema::FUNC_NAME});
            if ($filterObj === null) {
                if ($type === 'integer') {
                    $filterObj = $this->filters->get('number', $filter->{Schema::FUNC_NAME});
                    if ($filterObj === null) {
                        throw new FilterNotFoundException($type, $filter->{Schema::FUNC_NAME});
                    }
                } else {
                    throw new FilterNotFoundException($type, $filter->{Schema::FUNC_NAME});
                }
            }

            if (property_exists($filter, Schema::VARS_PROP)) {
                if (!is_object($filter->{Schema::VARS_PROP})) {
                    throw new SchemaKeywordException(
                        $filter,
                        Schema::VARS_PROP,
                        $filter->{Schema::VARS_PROP},
                        "'" . Schema::VARS_PROP . "' keyword must be an object, " . gettype($filter->{Schema::VARS_PROP}) . " given"
                    );
                }
                $vars = $this->deepClone($filter->{Schema::VARS_PROP});
                $this->resolveVars($vars, $document_data, $data_pointer);
                $vars = (array)$vars;
                if ($this->globalVars) {
                    $vars += $this->globalVars;
                }
            } else {
                $vars = $this->globalVars;
            }

            if (!$filterObj->validate($data, $vars)) {
                $valid = false;
                $filter_name = $filter->{Schema::FUNC_NAME};
                break;
            }

            unset($vars, $filterObj);
        }

        if (!$valid) {
            $bag->addError(new ValidationError($data, $data_pointer, $parent_data_pointer, $schema, Schema::FILTERS_PROP, [
                'type' => $type,
                'filter' => $filter_name,
            ]));
            return false;
        }

        return true;
    }
281174
protected function validationData()
    {
        return $this->merge([
            // Default value.
            'is_approved' => 'owner' == user('role') or ! setting('comments.moderate'),
            'parent_id' => $this->input('parent_id', null),
            // Default value from route.
            'commentable_id' => $this->route('commentable_id'),
            'commentable_type' => string_slug($this->route('commentable_type'), '_'),
            // Aditional default value.
            'user_ip' => $this->ip(),
        ])->all();
    }
383438
public function validateAllowEmpty()
    {
        $val = $this->val();

        if (($val === null || $val === '') && !$this->allowEmpty()) {
            return false;
        } else {
            return true;
        }
    }
42989
public function shouldApplyFilter() {
    if ($this->checkMentionTypes()) {
      return TRUE;
    }
    elseif ($this->textFormat && ($format = FilterFormat::load($this->textFormat))) {
      $filters = $format->get('filters');

      if (!empty($filters['filter_mentions']['status'])) {
        $this->settings = $filters['filter_mentions']['settings'];

        return $this->checkMentionTypes();
      }
    }

    return FALSE;
  }
1041038
final protected function validateFile () : bool
	{
		$file = $this->file;
		// Perform error checking on the file parameter parsed in
		if (!$file || empty($file) || !is_array($file)):
			// Error: nothing uploaded or wrong argument usage
			$this->error = "No file was uploaded.";
			return FALSE;
		endif;
		// Check if file is not empty
		if (!isset($file) || !is_uploaded_file($file['tmp_name'])):
			// Error: in file upload
			$this->error = "Uploaded file is Missing.";
			return FALSE;
		endif;
		// Check if file doesn't contain any error
		if ($file['error'] != 0):
			// Error: report what php says went wrong
			$this->error = $this->fileUploadErrors[$file['error']];
			return FALSE;
		endif;
		return TRUE;
	}
945257
public function validate($value)
  {
    $this->reset();

    $this->value = $value;

    $this->validateRequired();
    $this->validateFilters();

    return $this->isValid();
  }
1142551
public function isValid()
    {
        if (!filter_var($this->email, FILTER_VALIDATE_EMAIL)) {
            return false;
        }

        if (empty($this->userAgent)) {
            return false;
        }

        if (empty($this->series)) {
            return false;
        }

        if (empty($this->token)) {
            return false;
        }

        return true;
    }