{@inheritdoc}

@see \Mcustiel\SimpleRequest\Validator\MaxItems::validate()
772147
public function validate($value)
    {
        return ($value instanceof \stdClass && count((array) $value) <= $this->size)
            || parent::validate($value);
    }
721802
public function validate($value)
    {
        $return = new ValidateResult($value, false);

        if (!is_array($value)) {
            $return->errorObject = 'properties validation';
            //error
            $return->errorObject = new IncorrectParametersException([
                [
                    'type' => static::getType(),
                    'failure' => 'type'
                ]
            ]);
            return $return;
        } else {
            $propertiesCount = count($value);

            if ($propertiesCount < $this->minItems) {
                //error
                $return->errorObject = new IncorrectParametersException(
                    [
                        'type' => static::getType(),
                        'failure' => 'minItems'
                    ]
                );
                return $return;
            } elseif ($this->maxItems !== null
                && $propertiesCount > $this->maxItems
            ) {
                $return->errorObject = new IncorrectParametersException(
                    [
                        'type' => static::getType(),
                        'failure' => 'maxItems'
                    ]
                );
                //error
                return $return;
            }
        }

        if ($this->items !== null) {
            $errorItems = [];
            //Currently we support only a single type
            foreach ($value as $k => $v) {
                $validateItems = $this->items->validate($v);

                if (!$validateItems->status) {
                    $errorItems[$k] = $validateItems->errorObject->getParameters()[0];
                } else {
                    $value[$k] = $validateItems->value;
                }
            }

            if (!empty($errorItems)) {
                $return->errorObject = new IncorrectParametersException(
                    [
                        'type' => static::getType(),
                        'failure' => 'items',
                        'items' => [
                            $errorItems
                        ]
                    ]
                );
                return $return;
            }
        }

        //Check if contains duplicate items
        if ($this->uniqueItems
            && count($value) !== count(array_unique($value, SORT_REGULAR))
        ) {
            $return->errorObject = new IncorrectParametersException(
                [
                    'type' => static::getType(),
                    'failure' => 'uniqueItems'
                ]
            );
            return $return;
        }

        //Success
        $return->errorObject = null;
        $return->status = true;

        //type casted
        $return->value = $value;

        return $this->validateCommon($value, $return);
    }
673478
public function validate($validator)
    {
        $name = $this->name;

        // if field isn't visible, don't validate
        if (!$this->isSaveable()) {
            return true;
        }

        $this->getPasswordField()->setValue($this->value);
        $this->getConfirmPasswordField()->setValue($this->confirmValue);
        $value = $this->getPasswordField()->Value();

        // both password-fields should be the same
        if ($value != $this->getConfirmPasswordField()->Value()) {
            $validator->validationError(
                $name,
                _t('SilverStripe\\Forms\\Form.VALIDATIONPASSWORDSDONTMATCH', "Passwords don't match"),
                "validation"
            );

            return false;
        }

        if (!$this->canBeEmpty) {
            // both password-fields shouldn't be empty
            if (!$value || !$this->getConfirmPasswordField()->Value()) {
                $validator->validationError(
                    $name,
                    _t('SilverStripe\\Forms\\Form.VALIDATIONPASSWORDSNOTEMPTY', "Passwords can't be empty"),
                    "validation"
                );

                return false;
            }
        }

        // lengths
        $minLength = $this->getMinLength();
        $maxLength = $this->getMaxLength();
        if ($minLength || $maxLength) {
            $errorMsg = null;
            $limit = null;
            if ($minLength && $maxLength) {
                $limit = "{{$minLength},{$maxLength}}";
                $errorMsg = _t(
                    __CLASS__ . '.BETWEEN',
                    'Passwords must be {min} to {max} characters long.',
                    ['min' => $minLength, 'max' => $maxLength]
                );
            } elseif ($minLength) {
                $limit = "{{$minLength}}.*";
                $errorMsg = _t(
                    __CLASS__ . '.ATLEAST',
                    'Passwords must be at least {min} characters long.',
                    ['min' => $minLength]
                );
            } elseif ($maxLength) {
                $limit = "{0,{$maxLength}}";
                $errorMsg = _t(
                    __CLASS__ . '.MAXIMUM',
                    'Passwords must be at most {max} characters long.',
                    ['max' => $maxLength]
                );
            }
            $limitRegex = '/^.' . $limit . '$/';
            if (!empty($value) && !preg_match($limitRegex, $value)) {
                $validator->validationError(
                    $name,
                    $errorMsg,
                    "validation"
                );

                return false;
            }
        }

        if ($this->getRequireStrongPassword()) {
            if (!preg_match('/^(([a-zA-Z]+\d+)|(\d+[a-zA-Z]+))[a-zA-Z0-9]*$/', $value)) {
                $validator->validationError(
                    $name,
                    _t(
                        'SilverStripe\\Forms\\Form.VALIDATIONSTRONGPASSWORD',
                        'Passwords must have at least one digit and one alphanumeric character'
                    ),
                    "validation"
                );

                return false;
            }
        }

        // Check if current password is valid
        if (!empty($value) && $this->getRequireExistingPassword()) {
            if (!$this->currentPasswordValue) {
                $validator->validationError(
                    $name,
                    _t(
                        __CLASS__ . '.CURRENT_PASSWORD_MISSING',
                        'You must enter your current password.'
                    ),
                    "validation"
                );
                return false;
            }

            // Check this password is valid for the current user
            $member = Security::getCurrentUser();
            if (!$member) {
                $validator->validationError(
                    $name,
                    _t(
                        __CLASS__ . '.LOGGED_IN_ERROR',
                        "You must be logged in to change your password."
                    ),
                    "validation"
                );
                return false;
            }

            // With a valid user and password, check the password is correct
            $authenticators = Security::singleton()->getApplicableAuthenticators(Authenticator::CHECK_PASSWORD);
            foreach ($authenticators as $authenticator) {
                $checkResult = $authenticator->checkPassword($member, $this->currentPasswordValue);
                if (!$checkResult->isValid()) {
                    $validator->validationError(
                        $name,
                        _t(
                            __CLASS__ . '.CURRENT_PASSWORD_ERROR',
                            "The current password you have entered is not correct."
                        ),
                        "validation"
                    );
                    return false;
                }
            }
        }

        return true;
    }
694658
private function validateGreaterThan(): bool
    {
        if ($this->options['min'] !== null) {
            if ($this->options['inclusive'] === false && $this->value <= $this->options['min']) {
                $this->setError(self::VALIDATOR_ERROR_NUMBER_MUST_BE_HIGHER_THAN_MIN);
                return false;
            }

            if ($this->value < $this->options['min']) {
                $this->setError(self::VALIDATOR_ERROR_NUMBER_MUST_BE_HIGHER_OR_EQUAL_TO_MIN);
                return false;
            }
        }
        return true;
    }
310492
function validate($value, $key, $fields, $options, $exists, \CharlotteDunois\Validation\Validator $validator) {
        if(!$exists) {
            return false;
        }
        
        $n = \explode(',', $options);
        if(!\in_array($value, $n)) {
            return array('formvalidator_make_in', array('{0}' => $options));
        }
        
        return true;
    }
734614
public function validate($input)
    {
        /**
         * Validation criteria:
         * - 8 or 9 digits (only numbers!)
         * - Be able to pass the '11 test'
         * - Musn't contain any information.
         *   Cannot implement at this stage, not clear enough defined! Is 1337 information?
         * - Can not be sequential (nummeric)
         * - Is not 900000000 through 999999999 (test numbers)
         *
         * Based on public information: http://nl.wikipedia.org/wiki/Burgerservicenummer
         */

        // Validate: 8 or 9 digits (only numbers!)
        if (strlen($input) < 8 || strlen($input) > 9) {
            return false;
        }

        // Check if they are actually numbers
        // Alternatively, use ctype_digit($input) !
        if (preg_match('/[^0-9]/', $input)) {
            return false;
        }

        // See if the number passes the Eleventest (http://nl.wikipedia.org/wiki/Elfproef)
        if ($this->elevenTest($input)) {
            return false;
        }

        // Check if the numbers are sequential
        // Will not match when sequential numbers are used
        if (preg_match('/\d{5}/u', $input)) {
            return false;
        }

        // Validate if the number is not in the test range!
        return filter_var(
            $input,
            FILTER_VALIDATE_INT,
            array('options' => array('min_range' => '900000000', 'max_range' => '999999999'))
        );
    }
757674
protected function validate($value)
	{
		if ($value < $this->minValue || $value > $this->maxValue)
		{
			throw new InvalidArgumentException('Value ' . $value . ' is out of bounds (' . $this->minValue . '..' . $this->maxValue . ')');
		}
	}
266463
protected function validate($value){
        if( parent::validate($value) ){
            $length = mb_strlen($value, 'utf-8');
            if( $this->min && $this->min > $length ){
                throw new ValidateException(sprintf($this->__('Fields %s must be %d digits and more.'), $this->label, $this->min));
            }
            if( $this->max &&  $this->max < $length ){
                throw new ValidateException(sprintf($this->__('Fields %s must be %d digits and fewer.'), $this->label, $this->max));
            }
        }
        return true;
    }
218535
function minmaxValidator(value, testValue, validityName, limit, compareFunction) {
                if (!angular.isUndefined(testValue) && limit) {
                    if (!ngModelCtrl.$isEmpty(value) && compareFunction) {
                        return testValue;
                    } else {
                        return value;
                    }
                }
                else {
                    if (!limit) {
                        ngModelCtrl.$setValidity(validityName, !compareFunction);
                    }
                    return value;
                }
            }
868800
protected function validateMax($field, $value, $params)
    {
        if (!\is_numeric($value)) {
            return false;
        }

        if (\function_exists('\bccomp')) {
            return !(\bccomp($value, $params[0], 14) === 1);
        }

        return $params[0] >= $value;
    }
945298
public function validate(BaseValue $value)
    {
        $isValid = true;

        if ($this->constraints['maxStringLength'] !== false &&
            $this->constraints['maxStringLength'] !== 0 &&
            mb_strlen($value->text) > $this->constraints['maxStringLength']) {
            $this->errors[] = new ValidationError(
                'The string can not exceed %size% character.',
                'The string can not exceed %size% characters.',
                array(
                    '%size%' => $this->constraints['maxStringLength'],
                )
            );
            $isValid = false;
        }
        if ($this->constraints['minStringLength'] !== false &&
            $this->constraints['minStringLength'] !== 0 &&
            mb_strlen($value->text) < $this->constraints['minStringLength']) {
            $this->errors[] = new ValidationError(
                'The string cannot be shorter than %size% character.',
                'The string cannot be shorter than %size% characters.',
                array(
                    '%size%' => $this->constraints['minStringLength'],
                )
            );
            $isValid = false;
        }

        return $isValid;
    }
413191
function validate($value, $key, $fields, $options, $exists, \CharlotteDunois\Validation\Validator $validator) {
        if(!$exists) {
            return true;
        }
        
        if(!\is_callable($value)) {
            return 'formvalidator_make_callable';
        }
        
        if(empty($options)) {
            throw new \LogicException('Invalid options value given for callback rule');
        }
        
        /** @var \ReflectionMethod|\ReflectionFunction  $prototype */
        
        if(\is_array($value)) {
            $prototype = new \ReflectionMethod($value[0], $value[1]);
        } else {
            $prototype = new \ReflectionFunction($value);
        }
        
        $options = \explode('=', $options, 2);
        
        if(!empty($options[0])) {
            $params = \explode(',', $options[0]);
            
            /** @var \ReflectionParameter  $param */
            foreach($prototype->getParameters() as $pos => $param) {
                $type = $param->getType();
                
                if(!isset($params[$pos])) {
                    return array('formvalidator_make_callback_param_superfluos', array('{0}' => $pos));
                } elseif($params[$pos] === '') {
                    continue; // "mixed" type - wildcard
                } elseif(($type === null && $params[$pos] !== '') || \trim($params[$pos], '?') !== $type->getName()) {
                    return array('formvalidator_make_callback_param', array('{0}' => $pos, '{1}' => \trim($params[$pos], '?')));
                } elseif($params[$pos][0] === '?' && !$type->allowsNull()) {
                    return array('formvalidator_make_callback_param_nullable', array('{0}' => $pos));
                } elseif(\substr($params[$pos], -1) === '?' && !$param->isOptional()) {
                    return array('formvalidator_make_callback_param_optional', array('{0}' => $pos));
                }
            }
        }
        
        if(!empty($options[1])) {
            $return = $prototype->getReturnType();
            
            if($return === null) {
                return array('formvalidator_make_callback_return', array('{0}' => $options[1]));
            } elseif(($return->allowsNull() ? '?' : '').$return->getName() !== $options[1]) {
                return array('formvalidator_make_callback_return_type', array('{0}' => $options[1], '{1}' => $return->getName()));
            }
        }
        
        return true;
    }
189370
public function validate($value)
    {
        if (!(is_array($value) || $value instanceof \stdClass)) {
            return false;
        }

        return $this->executePropertiesValidation($this->convertToArray($value));
    }
924557
public function isValid($value)
    {
        $this->_setValue($value);
        if ($this->_max <= $value) {
            $this->_error(self::NOT_LESS);
            return false;
        }
        return true;
    }
943911
public static function validate($value, $maxLen, $errorMessage)
    {
        if (mb_strlen($value, 'UTF-8') <= $maxLen) {
            return true;
        }
        throw new DomainError($errorMessage);
    }
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;
    }
370220
public function validate($value)
    {
        $result = !$this->isRequired;
        if ($this->isRequired()) {
            $result = !empty($value);
        }
        if (is_callable($this->validator)) {
            $result = call_user_func($this->validator, $value);
        }

        return $result;
    }