@param string                    $path
@param mixed                     $value
@param ValidatorContextInterface $context
@param ValidatorInterface|null   $validator

@return ErrorInterface[]
777766
public function validate(
        string $path,
        $value,
        ValidatorContextInterface $context,
        ValidatorInterface $validator = null
    ) {
        if (null === $value || '' === $value) {
            return [];
        }

        if (!is_scalar($value) && !(is_object($value) && method_exists($value, '__toString'))) {
            return [new Error(
                $path,
                'constraint.numeric.invalidtype',
                ['type' => is_object($value) ? get_class($value) : gettype($value)]
            )];
        }

        $value = (string) $value;

        if (!is_numeric($value)) {
            return [new Error($path, 'constraint.numeric.notnumeric', ['value' => $value])];
        }

        return [];
    }
395518
public static function execute($value, ContextInterface $context): array
    {
        if (is_string($value) === true) {
            $lcValue = strtolower($value);
            if ($lcValue === 'true' || $lcValue === '1' || $lcValue === 'on' || $lcValue === 'yes') {
                $reply = static::createSuccessReply(true);
            } elseif ($lcValue === 'false' || $lcValue === '0' || $lcValue === 'off' || $lcValue === 'no') {
                $reply = static::createSuccessReply(false);
            } else {
                $reply = static::createErrorReply($context, $value, ErrorCodes::IS_BOOL, Messages::IS_BOOL, []);
            }
        } elseif (is_bool($value) === true) {
            $reply = static::createSuccessReply($value);
        } else {
            $reply = static::createErrorReply($context, $value, ErrorCodes::IS_BOOL, Messages::IS_BOOL, []);
        }

        return $reply;
    }
34739
public function validateTypes(&$value, $schema = null, JsonPointer $path, $i = null)
    {
        // check array
        if ($this->getTypeCheck()->isArray($value)) {
            $this->checkArray($value, $schema, $path, $i);
        }

        // check object
        if (LooseTypeCheck::isObject($value)) { // object processing should always be run on assoc arrays,
                                                // so use LooseTypeCheck here even if CHECK_MODE_TYPE_CAST
                                                // is not set (i.e. don't use $this->getTypeCheck() here).
            $this->checkObject(
                $value,
                $schema,
                $path,
                isset($schema->properties) ? $schema->properties : null,
                isset($schema->additionalProperties) ? $schema->additionalProperties : null,
                isset($schema->patternProperties) ? $schema->patternProperties : null,
                $this->appliedDefaults
            );
        }

        // check string
        if (is_string($value)) {
            $this->checkString($value, $schema, $path, $i);
        }

        // check numeric
        if (is_numeric($value)) {
            $this->checkNumber($value, $schema, $path, $i);
        }

        // check enum
        if (isset($schema->enum)) {
            $this->checkEnum($value, $schema, $path, $i);
        }

        // check const
        if (isset($schema->const)) {
            $this->checkConst($value, $schema, $path, $i);
        }
    }
1359754
public static function execute($value, ContextInterface $context): array
    {
        $reply = null;

        $result = [];
        if (is_string($value) === true) {
            $properties = $context->getProperties();
            $delimiter  = $properties->getProperty(static::PROPERTY_DELIMITER);
            $limit      = $properties->getProperty(static::PROPERTY_LIMIT);
            $result     = explode($delimiter, $value, $limit);
        } else {
            $reply = static::createErrorReply($context, $value, ErrorCodes::IS_STRING, Messages::IS_STRING, []);
        }

        return $reply !== null ? $reply : static::createSuccessReply($result);
    }
48306
public function getValidationErrors($value)
	{
		$errors = array();
		// ignore it if it's not an AgaviUploaded file, maybe it's not required
		if($value instanceof AgaviUploadedFile)
		{
			if(!empty($this->types) and !in_array($value->getMimeType(), $this->types))
			{
				$errors['mime_type'] = true; // we're not using it for messages (only
				// in this element) so if any error exists just set key of them to
				// avoid returning empty $errors
			}
		}
		return $errors;
	}
1315828
public static function execute($value, ContextInterface $context): array
    {
        return is_array($value) === true ?
            static::createSuccessReply($value) :
            static::createErrorReply($context, $value, ErrorCodes::IS_ARRAY, Messages::IS_ARRAY, []);
    }
852678
public static function execute($value, ContextInterface $context): array
    {
        $value = $context->getProperties()->getProperty(static::PROPERTY_VALUE);

        return static::createSuccessReply($value);
    }
609041
public static function execute($value, ContextInterface $context): array
    {
        return is_float($value) === true ?
            static::createSuccessReply($value) :
            static::createErrorReply($context, $value, ErrorCodes::IS_FLOAT, Messages::IS_FLOAT, []);
    }
429094
public static function execute($value, ContextInterface $context): array
    {
        assert(is_int($value) || is_string($value));

        $apiClass = $context->getProperties()->getProperty(static::PROPERTY_API_CLASS);

        /** @var FactoryInterface $apiFactory */
        $apiFactory = $context->getContainer()->get(FactoryInterface::class);

        /** @var CrudInterface $api */
        $api = $apiFactory->createApi($apiClass);

        $data   = $api->withIndexFilter((string)$value)->indexIdentities();
        $result = !empty($data);

        return $result === true ?
            static::createSuccessReply($value) :
            static::createErrorReply(
                $context,
                $value,
                ErrorCodes::EXIST_IN_DATABASE_SINGLE,
                Messages::EXIST_IN_DATABASE_SINGLE,
                []
            );
    }
750688
protected function getErrors($value, $constraints = null, $groups = null)
    {
        /** @var ValidatorInterface $validator */
        $validator = $this->getContainer()->get(Config::getServiceName());

        return $validator->validate($value, $constraints, $groups);
    }
1045809
public function isValid($value, $context = null)
    {
        if (! $this->useContext) {
            $context = (array) $value;
        }

        $cleanedValue = $this->cleanSearchValue($value);
        $match        = $this->objectRepository->findOneBy($cleanedValue);

        if (! is_object($match)) {
            return true;
        }

        $expectedIdentifiers = $this->getExpectedIdentifiers($context);
        $foundIdentifiers    = $this->getFoundIdentifiers($match);

        if (count(array_diff_assoc($expectedIdentifiers, $foundIdentifiers)) == 0) {
            return true;
        }

        $this->error(self::ERROR_OBJECT_NOT_UNIQUE, $value);
        return false;
    }
808939
function validate(string $value, \CharlotteDunois\Livia\Commands\Context $context, ?\CharlotteDunois\Livia\Arguments\Argument $arg = null) {
        $value = \mb_strtolower($value);
        return (\in_array($value, $this->truthy) || \in_array($value, $this->falsey));
    }
161514
public function isValid($value = null, $context = null)
    {
        if (!is_scalar($value)) {
            $this->error(self::INVALID);

            return false;
        }

        $this->setValue($value);

        $country = $this->getCountry();

        if (!array_key_exists($country, self::$postCodeRegex) && array_key_exists($country, $context)) {
            $country = $context[$country];
        }

        if (!array_key_exists($country, self::$postCodeRegex)) {
            $this->error(self::UNSUPPORTED);

            return false;
        }

        $format = self::$postCodeRegex[$country];

        if ($format[0] !== '/') {
            $format = '/^' . $format;
        }

        if ($format[strlen($format) - 1] !== '/') {
            $format .= '$/';
        }

        if (!preg_match($format, $value)) {
            $this->error(self::NO_MATCH);

            return false;
        }

        return true;
    }
806006
protected function validateDecimal($value, string $parameter, array $args = [], array $rules = null, array $context = null): ?string
    {
        if (count($args) == 0) {
            throw new ValidatorConfigException("Validator 'decimal' must have argument in validator list for parameter {$parameter}");
        }

        $decimals = (int)$args[0];

        if ($decimals <= 0) {
            throw new ValidatorConfigException("Validator 'decimal' has invalid value which is lower or equal to zero; for parameter={$parameter}");
        }

        if ($decimals > 100) {
            throw new ValidatorConfigException("Validator 'decimal' can't have that large argument; parameter={$parameter}");
        }

        //$value = $this->getValue($parameter);

        if ($value === null) {
            return null;
        }

        if (!is_scalar($value)) {
            return Message::getMessage(Message::PRIMITIVE, [
                'param' => $parameter
            ]);
        }

        $value = trim((string)$value);

        if ($value === '') {
            return null;
        }

        if (!is_numeric($value)) {
            return Message::getMessage(Message::NUMERIC, [
                'param' => $parameter,
                'value' => $value
            ]);
        }

        $parts = explode('.', $value);

        if (count($parts) == 1) {
            return null; // value is not decimal, it's probably integer, so it's ok
        }

        $valueDecimals = $parts[1];

        if (strlen($valueDecimals) > $decimals) {
            return Message::getMessage(Message::DECIMAL, [
                'param' => $parameter,
                'value' => $value,
                'decimals' => $decimals
            ]);
        }

        return null;
    }
197621
public static function execute($value, ContextInterface $context): array
    {
        $context->getStates()->setState(static::STATE_HAS_BEEN_CALLED, true);

        return static::createSuccessReply($value);
    }
1159494
public static function execute($value, ContextInterface $context): array
    {
        // parser guarantees that input will be either null or an [$type => $id] where type and id are scalars

        if ($value === null) {
            return static::createSuccessReply($value);
        }

        assert(is_array($value) === true && count($value) === 1);
        $index = reset($value);
        $type  = key($value);
        assert(is_scalar($index) === true && is_scalar($type) === true);
        $expectedType = $context->getProperties()->getProperty(static::PROPERTY_RESOURCE_TYPE);
        $reply        = $type === $expectedType ?
            static::createSuccessReply($index) :
            static::createErrorReply(
                $context,
                $type,
                ErrorCodes::INVALID_RELATIONSHIP_TYPE,
                Messages::INVALID_RELATIONSHIP_TYPE,
                []
            );

        return $reply;
    }
676253
private function validateClass(
        ValidatorContextInterface $context,
        ValidationClassMappingInterface $classMapping = null,
        string $path,
        $object
    ) {
        if (null === $classMapping) {
            return [];
        }

        if (!$this->isWithinGroup($context, $classMapping)) {
            return [];
        }

        $this->logPath($path);

        $errors = [];
        foreach ($classMapping->getConstraints() as $constraint) {
            $this->logConstraint($path, $constraint);

            foreach ($constraint->validate($path, $object, $context, $this) as $error) {
                $this->logError($path, $constraint, $error);

                $errors[] = $error;
            }
        }

        return $errors;
    }