Skip to content

Instantly share code, notes, and snippets.

@mmouih
Created January 5, 2024 01:21
Show Gist options
  • Save mmouih/6b16ee9ef73b50b20159c6e99413d840 to your computer and use it in GitHub Desktop.
Save mmouih/6b16ee9ef73b50b20159c6e99413d840 to your computer and use it in GitHub Desktop.
User Payload implements an payload interface
<?php
namespace App\Payload;
use Symfony\Component\Validator\Constraints as Assert;
use Symfony\Component\Validator\Constraints\Length;
use Symfony\Component\Validator\Constraints\Type;
readonly class User implements PayloadInterface
{
public function __construct(
#[Length(min: 3)]
#[Type(type: 'alpha')]
public string $name,
#[Assert\Valid]
public ?Address $address = null,
) {
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment