{@inheritDoc}
@see \rocket\ei\manage\entry\EiFieldConstraint::validate($eiField, $validationResult)
13356
public function validate(EiField $eiField, EiFieldValidationResult $validationResult) {
		if ($this->check($eiField)) return;

		$validationResult->addError(Message::createCodeArg('ei_impl_bool_field_must_be_selected_err', 
				array('field' => $this->labelLstr)));
	}
707027
public function validate(EiField $eiField, EiFieldValidationResult $validationResult) {
		if ($this->check($eiField)) return;
		
		$messageKey = null;
		switch ($this->operator) {
			case CriteriaComparator::OPERATOR_NOT_IN:
				$messageKey = 'ei_impl_relation_not_in_err';
				break;
			case CriteriaComparator::OPERATOR_IN:
				$messageKey = 'ei_impl_relation_in_err';
				break;
			case CriteriaComparator::OPERATOR_CONTAINS_NOT:
				$messageKey = 'ei_impl_relation_contains_not_err';
				break;
			case CriteriaComparator::OPERATOR_CONTAINS:
				$messageKey = 'ei_impl_relation_contains_err';
				break;
		}
		
		$validationResult->addError(Message::createCodeArg($messageKey, array('field' => $this->label,
				'target_entries' => implode(', ', $this->createTragetIdentityStrings()))));
	}
508232
public function validate() {

		if ($this->getFieldName() === null) {
			throw new ValidationException("'fieldName' can't be null", 'fieldName', $this);
		}
		if ($this->getSorting() === null) {
			throw new ValidationException("'sorting' can't be null", 'sorting', $this);
		}
	}
1270294
protected function validateValue($value, EiFieldValidationResult $validationResult) {
		if ($value != null) {
			CastUtils::assertTrue($value instanceof EiuFieldMap);
			
			$eiEntryValidationResult = new EiEntryValidationResult();
			$validationResult->addSubEiEntryValidationResult($eiEntryValidationResult);
			$value->validate($eiEntryValidationResult);
			return;
		}
		
		if ($this->eiProp->isMandatory()) {
			$validationResult->addError(Message::createCodeArg('common_field_required_err', 
					['field' => $this->eiProp->getLabelLstr()->t($this->eiu->getN2nLocale())], null, 'rocket'));
		}
	}
544368
public function validate()
    {
        $result = new ValidateResult();

        if ($this->get('disabled')) {
            return $result;
        }

        if ($this->required && !$this->checkRequired()) {
            return $result->setMessage(sprintf('Field %s value not allow empty.', $this->getLabel()))
                ->setResult(ValidateResult::STATUS_REQUIRED)
                ->setField($this);
        }

        if ($this->value !== null && $this->value !== '' && $this->validator && !$this->checkRule()) {
            return $result->setMessage(sprintf('Field %s validate fail.', $this->getLabel()))
                ->setResult(ValidateResult::STATUS_FAILURE)
                ->setField($this);
        }

        return $result;
    }
796964
public function validate(array $input = []): ValidationResult
    {
        $results = [];

        foreach ($this->rules as $key => $definition) {

            $rules = $this->parser->parseRulesDefinition($definition);

            $results[$key] = $rules->validate($key, $input);

        }

        return new ValidationResult($results, $this->translator);
    }
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;
    }
1360777
public function merge(ValidationResult $result)
    {
        return new static(
            array_merge($this->issues, $result->issues()),
            array_merge($this->matches, $result->matches())
        );
    }
714809
public function validateObjectFieldValue($value, $fieldName, $targetObject, &$validatorParams, $validatorKey) {

        if (sizeof($validatorParams) < ($this->mode == self::MODE_RANGE ? 2 : 1)) {
            throw new MisconfiguredValidatorException($validatorKey, $fieldName, $targetObject);
        }

        if (!$value) return true;

        switch ($this->mode) {
            case self::MODE_MIN:
                return strlen($value) >= $validatorParams[0];
            case self::MODE_MAX:
                return strlen($value) <= $validatorParams[0];
            case self::MODE_RANGE:
                return strlen($value) <= $validatorParams[1] && strlen($value) >= $validatorParams[0];
        }

    }
835710
protected function validateNumber($value, ValidationField $field) {
        $result = filter_var($value, FILTER_VALIDATE_FLOAT);
        if ($result === false) {
            $field->addTypeError($value, 'number');
            return Invalid::value();
        }

        $result = $this->validateNumberProperties($result, $field);

        return $result;
    }
942167
public function validate(ValidationResult $validationResult) {
        if (!$this->owner->ID) return; // The object is new, won't be looping.
        if (!$this->owner->LanguageID) return; // The object has no parent, won't be looping.
        if (!$this->owner->isChanged('LanguageID')) return; // The parent has not changed, skip the check for performance reasons.

        // Walk the hierarchy upwards until we reach the top, or until we reach the originating node again.
        $node=$this->owner;
        while($node) {
            if ($node->LanguageID==$this->owner->ID) {
                // Hierarchy is looping.
                $validationResult->error(
                    _t(
                        'Hierarchy.InfiniteLoopNotAllowed',
                        'Infinite loop found within the "{type}" hierarchy. Please change the parent to resolve this',
                        'First argument is the class that makes up the hierarchy.',
                        array('type' => $this->owner->class)
                    ),
                    'INFINITE_LOOP'
                );
                break;
            }
            $node=$node->LanguageID ? $node->Language() : null;
        }

        // At this point the $validationResult contains the response.
    }
347417
public static function invoke(
        array $fieldResults,
        array $options = []
    ): bool {
        /** @var ValidationResult $validationResult */
        foreach ($fieldResults as $validationResult) {
            if (!$validationResult->isValid()) {
                return false;
            }
        }

        return true;
    }
390748
public function validate($value)
    {
        $return = new ValidateResult($value, false);
        $failure = null;

        if (!is_object($value)) {
            $failure = 'type';
            //error
            goto err;
        }

        $valueProperties = get_object_vars($value);

        $valuePropertiesCount = count($valueProperties);

        if ($valuePropertiesCount < $this->minProperties) {
            //error
            $failure = 'minProperties';
            goto err;
        } elseif ($this->maxProperties !== null
            && $valuePropertiesCount > $this->maxProperties
        ) {
            $failure = 'maxProperties';
            //error
            goto err;
        }

        /**
         * @param \stdClass $propertyValues
         * @param array $expression
         * @return bool
         * @throws \Exception When an unknown function is set
         */
        $evaluate = function (
            \stdClass $propertyValues,
            array $expression
        ) use (&$evaluate) {
            $functions = (object) [
                /**
                 * @return bool
                 */
                'member' => function (
                    string $operator,
                    string $propertyKey,
                    array  $memberValues
                ) use ($propertyValues) {
                    if (!property_exists($propertyValues, $propertyKey)) {
                        return false;
                    }

                    $propertyValue = $propertyValues->{$propertyKey};

                    return in_array($propertyValue, $memberValues);
                },
                /**
                 * @return bool
                 * @since 0.10.0
                 */
                'subset' => function (
                    string $operator,
                    array  $subsetValues,
                    string $propertyKey
                ) use ($propertyValues) {
                    if (!property_exists($propertyValues, $propertyKey)) {
                        return false;
                    }

                    $propertyValue = $propertyValues->{$propertyKey};

                    if (!is_array($propertyValue)) {
                        $propertyValue = [$propertyValue];
                    }

                    $propertyValue = array_unique($propertyValue);
                    $subsetValues  = array_unique($subsetValues);

                    $intersect = array_intersect($propertyValue, $subsetValues);

                    return count($subsetValues) === count($intersect);
                },
                'or' => function (
                    string $operator,
                    array ...$list
                ) use (
                    $propertyValues,
                    &$evaluate
                ) {
                    return array_reduce(
                        $list,
                        function (
                            bool $carry,
                            array $item
                        ) use (
                            $propertyValues,
                            $evaluate
                        ) {
                            return $carry || $evaluate($propertyValues, $item);
                        },
                        false
                    );
                }
            ];

            $functionKey = $expression[0];

            //is atom (bool)
            if (is_bool($functionKey)) {
                return $functionKey;
            }

            if (!isset($functions->{$functionKey})) {
                throw new \Exception(sprintf(
                    'Unknown function "%s"',
                    $functionKey
                ));
            }

            $function = $functions->{$functionKey};

            return $function(...$expression);
        };

        //validate x-visibility
        if ($this->{'x-visibility'} !== null) {
            $xVisibility = $this->{'x-visibility'};

            foreach ($xVisibility as $propertyKey => $expression) {
                if (!property_exists($value, $propertyKey)) {
                    $this->required = array_diff(
                        $this->required,
                        [$propertyKey]
                    );
                } else {
                    //evaluate if property is visible
                    $evaluation = $evaluate(
                        $value,
                        $expression
                    );

                    /*//remove from required
                    if (!$evaluation) {
                        var_dump($this->required);

                        $this->required = array_diff(
                            $this->required,
                            [$propertyKey]
                        );

                        var_dump($this->required);
                    }*/

                    //if is defined and evaluation is false throw exception
                    if (!$evaluation && isset($value->{$propertyKey})) {
                        $return->errorObject = new IncorrectParametersException([
                            'type' => static::getType(),
                            'failure' => 'x-visibility',
                            'properties' => [$propertyKey]
                        ]);

                        return $return;
                    }
                }
            }
        }

        //Check if required properties are set and find if any of them are missing
        if ($this->required !== null || !empty($this->required)) {
            //Find missing properties
            $missingProperties = [];

            foreach ($this->required as $key) {
                if (!array_key_exists($key, $valueProperties)) {
                    //Push key to missing
                    $missingProperties[] = $key;
                }
            }

            if (!empty($missingProperties)) {
                //error, missing properties
                $return->errorObject = new MissingParametersException(
                    $missingProperties
                );
                return $return;
            }
        }

        //Return default if it's empty
        if ($valuePropertiesCount === 0 && property_exists($this, 'default')) {
            $return->value = $this->default;
            $return->status = true;
            return $return;
        }

        $overallPropertyStatus = true;
        $errorObjects = [];
        $missingObjects = [];
        $missingDependencies = [];

        //Validate all validator's properties
        foreach ($this->properties as $key => $property) {
            //If this property key exists in given $value, validate it
            if (array_key_exists($key, $valueProperties)) {
                $propertyValue = $valueProperties[$key];
                $propertyValidateResult = $property->validate($propertyValue);

                //Check dependencies, if key is set, it's dependencies must also be set
                if (isset($this->dependencies->{$key})) {
                    foreach ($this->dependencies->{$key} as $dependencyKey) {
                        if (!array_key_exists($dependencyKey, $valueProperties)) {
                            $missingDependencies[] = $dependencyKey;
                            //set status to false
                            $overallPropertyStatus = false;
                        }
                    }
                }

                //Determine $overallPropertyStatus
                $overallPropertyStatus = $overallPropertyStatus && $propertyValidateResult->status;

                if (!$propertyValidateResult->status) {
                    if (!$propertyValidateResult->errorObject) {
                        $errorObjects[$key] = [];
                    } else {
                        switch (get_class($propertyValidateResult->errorObject)) {
                            case MissingParametersException::class:
                                $missingObjects[$key] = $propertyValidateResult->errorObject->getParameters();
                                break;
                            case IncorrectParametersException::class:
                                $errorObjects[$key] = $propertyValidateResult->errorObject->getParameters();
                                break;
                            default:
                                $errorObjects[$key] = [];
                        }
                    }
                }

                //use type casted value
                $value->{$key} = $propertyValidateResult->value;
            } elseif (property_exists($property, 'default')) {
                //Else use default property's value
                $value->{$key} = $property->default;
            }
        }

        if (!$overallPropertyStatus) {
            $return->status = $overallPropertyStatus;

            //error
            $errorObject = [];

            if (!empty($errorObjects)) {
                $errorObject[] = [
                 'type' => static::getType(),
                 'failure' => 'properties',
                 'properties' => $errorObjects
                ];
            }

            if (!empty($missingObjects)) {
                $errorObject[] = [
                 'type' => static::getType(),
                 'failure' => 'missing',
                 'properties' => $missingObjects
                ];
            }

            if (!empty($missingDependencies)) {
                $errorObject[] = [
                    'type' => static::getType(),
                    'failure' => 'dependencies',
                    'properties' => $missingDependencies
                ];
            }

            if (!empty($missingDependencies)) {
                $return->errorObject = new MissingParametersException(
                    $missingDependencies
                );
            } elseif (!empty($missingObjects)) {
                $return->errorObject = new MissingParametersException(
                    $missingObjects
                );
            } else {
                $return->errorObject = new IncorrectParametersException(
                    $errorObject
                );
            }

            return $return;
        }

        //Check if additionalProperties are set
        if ($this->additionalProperties === false) {
            $foundAdditionalProperties = [];

            foreach ($valueProperties as $key => $property) {
                if (!property_exists($this->properties, $key)) {
                    $foundAdditionalProperties[] = $key;
                }
            }

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

        //success
        $return->status = true;

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

        return $this->validateCommon($value, $return);

        err:
        $return->errorObject = new IncorrectParametersException([
            'type' => static::getType(),
            'failure' => $failure
        ]);

        return $this->validateCommon($value, $return);
    }
336942
public function validate($value)
    {
        $result = parent::validate($value);
        return null === $result
            ? new EmailAddressValidationError($this)
            : $result;
    }
181606
public function validate(ValidationResult $validationResult)
    {
        $validator = new SynonymValidator(array(
            'SearchSynonyms',
        ));

        $validator->php(array(
            'SearchSynonyms' => $this->owner->SearchSynonyms
        ));

        $errors = $validator->getErrors();

        if (is_array($errors) || $errors instanceof Traversable) {
            foreach ($errors as $error) {
                $validationResult->addError($error['message']);
            }
        }
    }
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;
    }
556392
@Override
    public ValidationResult validate(PMContext ctx) {
        final ValidationResult res = new ValidationResult();
        final String fieldvalue = (String) ctx.getFieldValue();
        res.setSuccessful(true);
        if (!isName(fieldvalue)) {
            res.setSuccessful(false);
            res.getMessages().add(MessageFactory.error(ctx.getEntity(), ctx.getField(), get("msg", "")));
        }
        return res;
    }