NotEqualTo example

$this->validator->validate($valuenew Sequentially($constraints));

        $this->assertNoViolation();
    }

    public function testStopsAtFirstConstraintWithViolations()
    {
        $constraints = [
            new Type('string'),
            new Regex(['pattern' => '[a-z]']),
            new NotEqualTo('Foo'),
        ];

        $value = 'Foo';

        $this->expectValidateValue(0, $value[$constraints[0]]);
        $this->expectFailingValueValidation(1, $value[$constraints[1]], null, new ConstraintViolation('regex error', null, [], null, '', null, null, 'regex'));

        $this->validator->validate($valuenew Sequentially($constraints));

        $this->assertCount(1, $this->context->getViolations());
    }

    

class NotEqualToValidatorTest extends AbstractComparisonValidatorTestCase
{
    protected function createValidator(): NotEqualToValidator
    {
        return new NotEqualToValidator();
    }

    protected static function createConstraint(array $options = null): Constraint
    {
        return new NotEqualTo($options);
    }

    protected function getErrorCode(): ?string
    {
        return NotEqualTo::IS_EQUAL_ERROR;
    }

    public static function provideValidComparisons(): array
    {
        return [
            [1, 2],
            [
Home | Imprint | This part of the site doesn't use cookies.