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

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

        if ($value instanceof \DateTimeInterface) {
            return $this->validateDateTime($path, $value);
        }

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

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

        \DateTime::createFromFormat('!'.$this->format, $value);

        $dateTimeErrors = \DateTime::getLastErrors();

        return array_merge(
            $this->errorsByDateTimeLastErrors(
                $path,
                $value,
                'error',
                $dateTimeErrors['error_count'],
                $dateTimeErrors['errors']
            ),
            $this->errorsByDateTimeLastErrors(
                $path,
                $value,
                'warning',
                $dateTimeErrors['warning_count'],
                $dateTimeErrors['warnings']
            )
        );
    }
852678
public static function execute($value, ContextInterface $context): array
    {
        $value = $context->getProperties()->getProperty(static::PROPERTY_VALUE);

        return static::createSuccessReply($value);
    }
351771
private function errorsByDateTimeLastErrors(
        string $path,
        string $value,
        string $errorType,
        int $dateTimeErrorCount,
        array $dateTimeErrors
    ): array {
        if (0 === $dateTimeErrorCount) {
            return [];
        }

        $errors = [];
        foreach ($dateTimeErrors as $message) {
            $errors[] = new Error(
                $path,
                sprintf('constraint.datetime.%s', $errorType),
                ['message' => $message, 'format' => $this->format, 'value' => $value]
            );
        }

        return $errors;
    }
569831
protected function validateNull($value, ValidationField $field) {
        if ($value === null) {
            return null;
        }
        $field->addError('type', ['messageCode' => 'The value should be null.', 'type' => 'null']);
        return Invalid::value();
    }
936349
public function validate($value, $constraints = null, $groups = null)
    {
        return $this->validator->validate($value, $constraints, $groups);
    }
905729
public function validate($field, $value, $validator) {
		if($this->match_keys === true) {
			return array_key_exists($value, $this->array);
		} else {
			return in_array($value, $this->array);
		}
	}
1030355
public static function execute($value, ContextInterface $context): array
    {
        if (is_string($value) === true || is_numeric($value) === true) {
            return static::createSuccessReply((float)$value);
        }

        return static::createErrorReply($context, $value, ErrorCodes::IS_FLOAT, Messages::IS_FLOAT, []);
    }
25912
public function convert($value, string $path = '', bool $allowSerializeEmpty = false): AbstractNode
    {
        if (null === $value) {
            return NullNode::create();
        }

        $type = gettype($value);

        if (!isset($this->typeMapping[$type])) {
            throw new \InvalidArgumentException(
                sprintf('Type %s is not supported, at path %s', is_object($value) ? get_class($value) : $type, $path)
            );
        }

        $node = $this->typeMapping[$type];

        return $node::create($value, $allowSerializeEmpty);
    }
1296492
public static function execute($value, ContextInterface $context): array
    {
        $reply = null;

        $result = [];
        if (is_array($value) === true) {
            foreach ($value as $key => $mightBeString) {
                if (is_string($mightBeString) === true || is_numeric($mightBeString) === true) {
                    $result[$key] = (int)$mightBeString;
                } else {
                    $reply = static::createErrorReply(
                        $context,
                        $mightBeString,
                        ErrorCodes::IS_STRING,
                        Messages::IS_STRING,
                        []
                    );
                    break;
                }
            }
        } else {
            $reply = static::createErrorReply($context, $value, ErrorCodes::IS_ARRAY, Messages::IS_ARRAY, []);
        }

        return $reply !== null ? $reply : static::createSuccessReply($result);
    }
170054
public static function execute($value, ContextInterface $context): array
    {
        $properties      = $context->getProperties();
        $filterId        = $properties->getProperty(static::PROPERTY_FILTER_ID);
        $filterOptions   = $properties->getProperty(static::PROPERTY_FILTER_OPTIONS);
        $errorCode       = $properties->getProperty(static::PROPERTY_FILTER_ERROR_CODE);
        $messageTemplate = $properties->getProperty(static::PROPERTY_MESSAGE_TEMPLATE);

        $output = filter_var($value, $filterId, $filterOptions);

        return $output !== false ?
            static::createSuccessReply($output) :
            static::createErrorReply($context, $value, $errorCode, $messageTemplate, [$filterId, $filterOptions]);
    }
813330
public function runValidators($value)
    {
        if (empty($value)) {
            return;
        }

        // collect all validation errors for this field
        $validationErrors = [];
        foreach ($this->getFieldValidators() as $validator) {
            try {
                $validator($value);
            } catch (ValidationError $error) {
                $validationErrors = array_merge($validationErrors, $error->getErrorList());
            }
        }

        if (!empty($validationErrors)) {
            throw new ValidationError($validationErrors);
        }
    }
16055
private function validateDateTime(string $path, \DateTimeInterface $value): array
    {
        $expectedValue = \DateTime::createFromFormat(
            '!'.$this->format,
            $value->format($this->format),
            $value->getTimezone()
        );

        if ($expectedValue->format('c') !== $value->format('c')) {
            return [
                new Error(
                    $path,
                    'constraint.datetime.format',
                    ['format' => $this->format, 'value' => $value->format('c')]
                ),
            ];
        }

        return [];
    }
836154
public function getContextValue($context, $path)
    {
        $accessor = PropertyAccess::createPropertyAccessor();

        return $accessor->getValue($context, $path);
    }
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;
    }
1111792
public function isValid($value, array $context = null)
    {
        $this->setValue($value);

        $token = $this->getToken();

        if (!$this->getLiteral() && $context !== null) {
            if (is_array($token)) {
                while (is_array($token)) {
                    $key = key($token);
                    if (!isset($context[$key])) {
                        break;
                    }
                    $context = $context[$key];
                    $token   = $token[$key];
                }
            }

            // if $token is an array it means the above loop didn't went all the way down to the leaf,
            // so the $token structure doesn't match the $context structure
            if (is_array($token) || !isset($context[$token])) {
                $token = $this->getToken();
            } else {
                $token = $context[$token];
            }
        }

        if ($token === null) {
            $this->error(self::MISSING_TOKEN);
            return false;
        }

        $strict = $this->getStrict();
        if (!($strict && ($value !== $token)) || (!$strict && ($value != $token))) {
            $this->error(self::SAME);
            return false;
        }

        return true;
    }
1055219
public function validateRequest(ServerRequestInterface $request, string $path): ValidationResult
    {
        $operation         = $this->description->getPath($path)->getOperation($request->getMethod());
        $schema            = $operation->getRequestSchema();
        $requestParameters = $this->parameterAssembler->getRequestParameters($request, $operation);

        return $this->validator->validate($schema, $requestParameters);
    }
107811
public function isValid($value, $context = null)
    {
        if (! is_array($value) && ! is_array($context)) {
            $this->error(self::MISSING_VALUE);
            return false;
        }

        if (! is_array($value) && is_array($context)) {
            $value = $context;
        }

        if (empty($value[$this->responseField])) {
            $this->error(self::MISSING_VALUE);
            return false;
        }

        $service = $this->getService();

        $res = $service->verify($value[$this->responseField]);
        if (! $res) {
            $this->error(self::ERR_CAPTCHA);
            return false;
        }

        if (! $res->isSuccess()) {
            $result = $res->getErrorCodes();
            $this->error(self::BAD_CAPTCHA, end($result));
            return false;
        }

        return true;
    }