Isbn example

#[Assert\Isbn([         'type' => 'isbn10',
        'message' => 'custom Isbn message from attribute with options as array',
    ])]
    public string $isbn2;
}

class Foo2
{
    public function index()
    {
        $constraint1 = new Assert\Isbn('isbn10', 'custom Isbn message'); // no way to handle those arguments (not named, not in associative array).         $constraint2 = new Assert\Isbn([
            'type' => 'isbn10',
            'message' => 'custom Isbn message with options as array',
        ]);
        $constraint3 = new Assert\Isbn(message: 'custom Isbn message from named argument');
        $constraint4 = new Assert\Length(exactMessage: 'custom Length exact message from named argument');
        $constraint5 = new Assert\Length(exactMessage: 'custom Length exact message from named argument 1/2', minMessage: 'custom Length min message from named argument 2/2');
    }
}
public static function getInvalidIsbn()
    {
        return array_merge(
            self::getInvalidIsbn10(),
            self::getInvalidIsbn13()
        );
    }

    public function testNullIsValid()
    {
        $constraint = new Isbn(true);

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

        $this->assertNoViolation();
    }

    public function testEmptyStringIsValid()
    {
        $constraint = new Isbn(true);

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

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