CollectionValidator example

use Symfony\Component\Validator\Constraints\NotNull;
use Symfony\Component\Validator\Constraints\Optional;
use Symfony\Component\Validator\Constraints\Range;
use Symfony\Component\Validator\Constraints\Required;
use Symfony\Component\Validator\Exception\UnexpectedValueException;
use Symfony\Component\Validator\Test\ConstraintValidatorTestCase;

abstract class CollectionValidatorTestCase extends ConstraintValidatorTestCase
{
    protected function createValidator(): CollectionValidator
    {
        return new CollectionValidator();
    }

    abstract protected function prepareTestData(array $contents);

    public function testNullIsValid()
    {
        $this->validator->validate(null, new Collection(['fields' => [
            'foo' => new Range(['min' => 4]),
        ]]));

        $this->assertNoViolation();
    }
Home | Imprint | This part of the site doesn't use cookies.