ExpressionValidator example

use Symfony\Component\Validator\Constraints\NotNull;
use Symfony\Component\Validator\Constraints\Range;
use Symfony\Component\Validator\ConstraintViolation;
use Symfony\Component\Validator\Test\ConstraintValidatorTestCase;
use Symfony\Component\Validator\Tests\Fixtures\NestedAttribute\Entity;
use Symfony\Component\Validator\Tests\Fixtures\ToString;

class ExpressionValidatorTest extends ConstraintValidatorTestCase
{
    protected function createValidator(): ExpressionValidator
    {
        return new ExpressionValidator();
    }

    public function testExpressionIsEvaluatedWithNullValue()
    {
        $constraint = new Expression([
            'expression' => 'false',
            'message' => 'myMessage',
        ]);

        $this->validator->validate(null, $constraint);

        
Home | Imprint | This part of the site doesn't use cookies.