{@inheritdoc}

@see \Mcustiel\SimpleRequest\Validator\AbstractAnnotationSpecifiedValidator::validate()
189370
public function validate($value)
    {
        if (!(is_array($value) || $value instanceof \stdClass)) {
            return false;
        }

        return $this->executePropertiesValidation($this->convertToArray($value));
    }
470632
public function validate(array $toValidate = [])
    {
        $return = true;
        $validators = $this->getValidatorsForFields($toValidate);
        foreach ($validators as $validator) {
            $res = $validator->validate($toValidate);
            if ($res === false && $return === true) {
                $return = false;
            }
        }
        $elements = $this->getElements();
        foreach ($elements as $el) {
            if (
                (!empty($toValidate) && !in_array($el->getName(), $toValidate))
                || !($el instanceof \marvin255\serviform\interfaces\HasValidators)
            ) {
                continue;
            }
            $res = $el->validate();
            if ($res === false && $return === true) {
                $return = false;
            }
        }

        return $return;
    }
1227192
public function validate(array $parameters = array()) {
        $validated= false;
        $this->reset();
        $stopOnFail= isset($parameters['stopOnFail']) && $parameters['stopOnFail']
                ? true
                : false;
        $stopOnRuleFail= isset($parameters['stopOnRuleFail']) && $parameters['stopOnRuleFail']
                ? true
                : false;
        if (!empty($this->object->_validationRules)) {
            foreach ($this->object->_validationRules as $column => $rules) {
                $this->results[$column]= $this->object->isValidated($column);
                if (!$this->results[$column]) {
                    $columnResults= array();
                    foreach ($rules as $ruleName => $rule) {
                        $result= false;
                        if (is_array($rule['parameters'])) $rule['parameters']['column'] = $column;
                        switch ($rule['type']) {
                            case 'callable':
                                $callable= $rule['rule'];
                                if (is_callable($callable)) {
                                     $result= call_user_func_array($callable, array($this->object->_fields[$column],$rule['parameters']));
                                    if (!$result) $this->addMessage($column, $ruleName, isset($rule['parameters']['message']) ? $rule['parameters']['message'] : $ruleName . ' failed');
                                } else {
                                    $this->object->xpdo->log(xPDO::LOG_LEVEL_ERROR, "Validation function {$callable} is not a valid callable function.");
                                }
                                break;
                            case 'preg_match':
                                $result= (boolean) preg_match($rule['rule'], $this->object->_fields[$column]);
                                if (!$result) $this->addMessage($column, $ruleName, isset($rule['parameters']['message']) ? $rule['parameters']['message'] : $ruleName . ' failed');
                                if ($this->object->xpdo->getDebug() === true)
                                    $this->object->xpdo->log(xPDO::LOG_LEVEL_DEBUG, "preg_match validation against {$rule['rule']} resulted in " . print_r($result, 1));
                                break;
                            case 'xPDOValidationRule':
                                if ($ruleClass= $rule['rule']) {
                                    if (strpos($ruleClass, '\\') === false && strpos($ruleClass, '.') === false) {
                                        $ruleClass = __NAMESPACE__ . '\\' . $ruleClass;
                                    }
                                    if ($ruleObject= new $ruleClass($this, $column, $ruleName)) {
                                        $callable= array($ruleObject, 'isValid');
                                        if (is_callable($callable)) {
                                            $callableParams= array($this->object->_fields[$column], $rule['parameters']);
                                            $result= call_user_func_array($callable, $callableParams);
                                        } else {
                                            $this->object->xpdo->log(xPDO::LOG_LEVEL_ERROR, "Validation rule class {$rule['rule']} does not have an isValid() method.");
                                        }
                                    }
                                } else {
                                    $this->object->xpdo->log(xPDO::LOG_LEVEL_ERROR, "Could not load validation rule class: {$rule['rule']}");
                                }
                                break;
                            default:
                                $this->object->xpdo->log(xPDO::LOG_LEVEL_ERROR, "Unsupported validation rule: " . print_r($rule, true));
                                break;
                        }
                        $columnResults[$ruleName]= $result;
                        if (!$result && $stopOnRuleFail) {
                            break;
                        }
                    }
                    $this->results[$column]= !in_array(false, $columnResults, true) ? true : false;
                    if (!$this->results[$column] && $stopOnFail) {
                        break;
                    }
                }
                if ($this->results[$column]) {
                    $this->object->_validated[$column]= $column;
                }
            }
            if (empty($this->results) || !in_array(false, $this->results, true)) {
                $validated = true;
                if ($this->object->xpdo->getDebug() === true)
                    $this->object->xpdo->log(xPDO::LOG_LEVEL_WARN, "Validation succeeded: " . print_r($this->results, true));
            } elseif ($this->object->xpdo->getDebug() === true) {
                $this->object->xpdo->log(xPDO::LOG_LEVEL_WARN, "Validation failed: " . print_r($this->results, true));
            }
        } else {
            if ($this->object->xpdo->getDebug() === true) $this->object->xpdo->log(xPDO::LOG_LEVEL_DEBUG, "Validation called but no rules were found.");
            $validated = true;
        }
        return $validated;
    }
283749
public function validate($value)
    {
        if (!$value instanceof DOMDocument) {
            $this->errors[] = TypeValidationError::xmlValidationFailed('Expected value of type DOMDocument');

            return;
        }

        $originalErrorLevel = \libxml_use_internal_errors(true);
        $value->schemaValidateSource($this->xml);
        $errors = \libxml_get_errors();
        \libxml_clear_errors();
        if ($errors) {
            foreach ($errors as $error) {
                $this->errors[] = TypeValidationError::xmlValidationFailed($error->message);
            }

            return;
        }

        \libxml_use_internal_errors($originalErrorLevel);
    }
767296
protected function validate(array $options)
    {
        if (! isset($options['method'])) {
            throw new \InvalidArgumentException('method property is missing');
        } elseif (! in_array($options['method'], ['GET', 'POST', 'PUT', 'PATCH', 'OPTIONS', 'DELETE', 'HEAD'])) {
            throw new \InvalidArgumentException('method property is not valid');
        } elseif (! isset($options['path'])) {
            throw new \InvalidArgumentException('path property is missing');
        } elseif (isset($options['since'])
            && ! preg_match('#^' . Application::API_VERSION_REG_EXP . '$#', $options['since'])) {
            throw new \InvalidArgumentException('since property is not valid');
        } elseif (isset($options['until'])
            && ! preg_match('#^' . Application::API_VERSION_REG_EXP . '$#', $options['until'])) {
            throw new \InvalidArgumentException('until property is not valid');
        }
    }
246295
public function validate($removeRequired = false)
    {
        if ($removeRequired) {
            $this->removeRequired();
        }
        $content = $this->request->all();
        $messages = (method_exists($this, 'messages') && is_array($this->messages())) ? array_merge($this->messages, $this->messages()) : $this->messages;
        $this->validator = $this->app['validator']->make($content, $this->getRules(), $messages);
        /** get iterable keys and iterate */
        $mappings = $this->mappings();
        foreach ($mappings as $key => $value) {
            if (is_array($value) && class_exists($value['class']) && array_get($content, $key)) {
                $class = new $value['class']($this->app);
                $messages = (method_exists($class, 'messages') && is_array($class->messages())) ? array_merge($this->messages, $class->messages()) : $this->messages;
                $this->validator->iterate($this->request, $key, $class, $messages);
            }
        }

        if (method_exists($this, 'getSometimes')) {
            call_user_func_array([$this, 'getSometimes'], [$this->validator]);
        }

        if ($this->validator->fails()) {
            throw new ValidationException($this->validator->errors());
            
        }

        return $this->getDbValues($this->validator->getData(), $this->mappings());
    }
1167903
public function validate(&$error = null)
    {
        if (!$this->isCountryCodeValid()) {
            $error = 'IBAN country code not valid or not supported';
        } elseif (!$this->isLengthValid()) {
            $error = 'IBAN length is invalid';
        } elseif (!$this->isFormatValid()) {
            $error = 'IBAN format is invalid';
        } elseif (!$this->isChecksumValid()) {
            $error = 'IBAN checksum is invalid';
        } else {
            $error = '';
            return true;
        }

        return false;
    }
111878
function validate($value, $key, $fields, $options, $exists, \CharlotteDunois\Validation\Validator $validator) {
        if(isset($_FILES[$key])) {
            if(!\file_exists($_FILES[$key]['tmp_name'])) {
                return 'formvalidator_make_image';
            }
            
            $size = \getimagesize($_FILES[$key]['tmp_name']);
        } else {
            if(!$exists) {
                return false;
            }
            
            $size = @\getimagesizefromstring($value);
        }
        
        if(!$size) {
            return 'formvalidator_make_image';
        }
        
        return true;
    }
304020
private function validate($decoded): void
    {
        // Validate it is an array
        if (! Validator::arrayType()->length(1, 2)->validate($decoded)) {
            throw new AnnotationParseException(
                '"construct" annotation content is invalid (must contains parameters array, and maybe a class)'
            );
        }

        $size = count($decoded);

        // Validate that if size is 2, first value is a string
        if ($size === 2 && ! Validator::stringType()->validate($decoded[0])) {
            throw new AnnotationParseException(
                '"construct" annotation content is invalid (constructor class must be a string)'
            );
        }
        // Validate that last value is an array
        if (! Validator::arrayVal()
            ->each(Validator::stringType(), Validator::intType())->validate($decoded[$size - 1])) {
            throw new AnnotationParseException(
                '"construct" annotation content is invalid (constructor parameters must be a array of string)'
            );
        }
    }
694960
public function validate(&$params)
    {
        if (!is_array($params)) {
            throw new InvalidArgumentException('Please use array params when call validate.');
        }
        $rules = $this->validators;

        if (count($params) < count($rules)) {
            if (!isset($this->defaultValues) || empty($this->defaultValues)) {
                throw new InvalidArgumentException('The params are less than validators.');
            }
            $defaultValues = $this->defaultValues;

            foreach ($defaultValues as $key => $value) {
                if (!isset($params[$key])) {
                    $params[$key] = $value;
                }

            }
        } elseif (count($params) > count($rules)) {
            throw new InvalidArgumentException('The params are more than validators.');
        }
        foreach ($rules as $key => $rule) {
            if (isset($params[$key])) {
                if (is_array($rule)) {
                    $isError = true;

                    foreach ($rule as $subRule) {
                        if (call_user_func([$subRule, 'validate'], $params[$key]) === true) {
                            $isError = false;
                            break;
                        }
                    }
                    if ($isError) {
                        throw new RuntimeException('Wrong type of ' . $this->method . ' method argument ' . $key . '.');
                    }
                } else {
                    if (call_user_func([$rule, 'validate'], $params[$key]) === false) {
                        throw new RuntimeException('Wrong type of ' . $this->method . ' method argument ' . $key . '.');
                    }
                }
            } else {
                throw new RuntimeException($this->method . ' method argument ' . $key . ' doesn\'t have default value.');
            }
        }
        return true;
    }
66483
protected function _actionValidate($context)
    {
        $data = $context->data;
        $key = $data->key;
        $value = $data->value;
        $method = 'validate'.ucfirst($key);
        $result = true;
        $result = $this->getValidator()->$method($value);
        $output = $this->getValidator()->getMessage();

        if ($result === false) {
            $context->response->status = AnHttpResponse::PRECONDITION_FAILED;

            if (is_string($output)) {
                $output = array('errorMsg' => $output);
            }

            $context->response->validation = json_encode($output);
        } else {
            $context->response->validation = json_encode($output);
        }
    }
534753
protected function validate($value)
    {
        if (!$this->validators instanceof IValidatorCollection) {
            return true;
        }

        $isValid = $this->validators->isValid($value);
        $this->messages = $this->validators->getMessages();

        return $isValid;
    }
507361
protected function _validate($value)
    {
        $value = trim($value);
        $pattern = ComHashtagsDomainEntityHashtag::PATTERN_HASHTAG;

        return (is_string($value) && (preg_match($pattern, $value)) == 1);
    }
337795
static function validate($value, \Zend_Validate_Interface $validator) {
		return
			is_null($value)
			&& isset($validator->{self::$SKIP_ON_NULL})
			&& $validator->{self::$SKIP_ON_NULL}
			|| $validator->isValid($value)
		;
	}
82432
public function validate( $input )
    {
        // Check for minimum constraint
        if ( ( $this->min !== false ) &&
             ( $input < $this->min ) )
        {
            throw new phpillowValidationException(
                'Input value %input is not bigger or equal then %minimum.',
                array(
                    'input'   => $input,
                    'minimum' => $this->min,
                )
            );
        }

        // Check for maximum constraint
        if ( ( $this->max !== false ) &&
             ( $input > $this->max ) )
        {
            throw new phpillowValidationException(
                'Input value %input is not lesser or equal then %maximum.',
                array(
                    'input'   => $input,
                    'maximum' => $this->max,
                )
            );
        }

        return (int) $input;
    }
879260
function validate($value, $key, $fields, $options, $exists, \CharlotteDunois\Validation\Validator $validator) {
        if(isset($_FILES[$key])) {
            if(!\file_exists($_FILES[$key]['tmp_name'])) {
                return 'formvalidator_make_invalid_file';
            }
            
            $size = \getimagesize($_FILES[$key]['tmp_name']);
        } else {
            if(!$exists) {
                return false;
            }
            
            $size = @\getimagesizefromstring($value);
        }
        
        if(!$size) {
            return 'formvalidator_make_invalid_file';
        }
        
        $n = \explode(',', $options);
        foreach($n as $x) {
            $k = \explode('=', $x);
            switch($k[0]) {
                case 'min_width': // @codeCoverageIgnore
                    if($k[1] > $size[0]) {
                        return array('formvalidator_make_min_width', array('{0}' => $options));
                    }
                break;
                case 'min_height': // @codeCoverageIgnore
                    if($k[1] > $size[1]) {
                        return array('formvalidator_make_min_height', array('{0}' => $options));
                    }
                break;
                case 'width': // @codeCoverageIgnore
                    if($k[1] != $size[0]) {
                        return array('formvalidator_make_width', array('{0}' => $options));
                    }
                break;
                case 'height': // @codeCoverageIgnore
                    if($k[1] != $size[1]) {
                        return array('formvalidator_make_height', array('{0}' => $options));
                    }
                break;
                case 'max_width': // @codeCoverageIgnore
                    if($k[1] < $size[0]) {
                        return array('formvalidator_make_max_width', array('{0}' => $options));
                    }
                break;
                case 'max_height': // @codeCoverageIgnore
                    if($k[1] < $size[1]) {
                        return array('formvalidator_make_max_height', array('{0}' => $options));
                    }
                break;
                case 'ratio': // @codeCoverageIgnore
                    if(\mb_strpos($k[1], '/') !== false) {
                        $k[1] = \explode('/', $k[1]);
                        $k[1] = $k[1][0] / $k[1][1];
                    }
                    
                    if(\number_format(($size[0] / $size[1]), 1) != \number_format($k[1], 1)) {
                        return array('formvalidator_make_ratio', array('{0}' => $options));
                    }
                break;
            }
        }
        
        return true;
    }
482889
public function validate($value)
    {
        if ($this->notBeEmpty($value)) {
            $value = json_decode($value);
            if ($value !== null) {
                return true;
            } else {
                return false;
            }
        } else {
            return false;
        }
    }