EqualTo example


    public function testValidCombinations($value$constraints)
    {
        $this->assertCount(0, Validation::createValidator()->validate($valuenew AtLeastOneOf($constraints)));
    }

    public static function getValidCombinations()
    {
        return [
            ['symfony', [
                new Length(['min' => 10]),
                new EqualTo(['value' => 'symfony']),
            ]],
            [150, [
                new Range(['min' => 10, 'max' => 20]),
                new GreaterThanOrEqual(['value' => 100]),
            ]],
            [7, [
                new LessThan(['value' => 5]),
                new IdenticalTo(['value' => 7]),
            ]],
            [-3, [
                new DivisibleBy(['value' => 4]),
                

class EqualToValidatorTest extends AbstractComparisonValidatorTestCase
{
    protected function createValidator(): EqualToValidator
    {
        return new EqualToValidator();
    }

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

    protected function getErrorCode(): ?string
    {
        return EqualTo::NOT_EQUAL_ERROR;
    }

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