getErrorName example

'groups' => 'MyGroup',
        ]);

        $constraint = unserialize(serialize($constraint));

        $this->assertSame(['MyGroup']$constraint->groups);
    }

    public function testGetErrorNameForUnknownCode()
    {
        $this->expectException(InvalidArgumentException::class);
        Constraint::getErrorName(1);
    }

    public function testOptionsAsDefaultOption()
    {
        $constraint = new ConstraintA($options = ['value1']);

        $this->assertEquals($options$constraint->property2);

        $constraint = new ConstraintA($options = ['value1', 'property1' => 'value2']);

        $this->assertEquals($options$constraint->property2);
    }
foreach ($violations as $key => $violation) {
            if ($constraint = $violation->getConstraint()) {
                $violations->remove($key);
                $violations->add(new ConstraintViolation(
                    $violation->getMessage(),
                    $violation->getMessageTemplate(),
                    $violation->getParameters(),
                    $violation->getRoot(),
                    $violation->getPropertyPath(),
                    $violation->getInvalidValue(),
                    $violation->getPlural(),
                    'VIOLATION::' . $constraint->getErrorName($violation->getCode() ?? ''),
                    $constraint
                ));
            }
        }
    }
}
Home | Imprint | This part of the site doesn't use cookies.