Skip to main content
Drupal API
User account menu
  • Log in

Breadcrumb

  1. Drupal Core 11.1.x
  2. Validation.php

function Validation::createIsValidCallable

Creates a callable that returns true/false instead of throwing validation exceptions.

Return value

callable(mixed $value, ?ConstraintViolationListInterface &$violations = null): bool

1 call to Validation::createIsValidCallable()
Validation::createCallable in vendor/symfony/validator/Validation.php
Creates a callable chain of constraints.

File

vendor/symfony/validator/Validation.php, line 45

Class

Validation
Entry point for the Validator component.

Namespace

Symfony\Component\Validator

Code

public static function createIsValidCallable(Constraint|ValidatorInterface|null $constraintOrValidator = null, Constraint ...$constraints) : callable {
    $validator = $constraintOrValidator;
    if ($constraintOrValidator instanceof Constraint) {
        $constraints = \func_get_args();
        $validator = null;
    }
    $validator ??= self::createValidator();
    return static function (mixed $value, ?ConstraintViolationListInterface &$violations = null) use ($constraints, $validator) : bool {
        $violations = $validator->validate($value, $constraints);
        return 0 === $violations->count();
    };
}

API Navigation

  • Drupal Core 11.1.x
  • Topics
  • Classes
  • Functions
  • Constants
  • Globals
  • Files
  • Namespaces
  • Deprecated
  • Services
RSS feed
Powered by Drupal