Created
November 11, 2021 16:55
-
-
Save atillay/516817b237d67dc26171bb9633765865 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
namespace App\Entity; | |
use ApiPlatform\Core\Annotation\ApiResource; | |
use Symfony\Component\Validator\Constraints as Assert; | |
/** | |
* @ApiResource( | |
* collectionOperations={ | |
* "post"={ | |
* "validation_groups"={"Default", "my-entity:post"}}, | |
* } | |
* }, | |
* itemOperations={ | |
* "put"={ | |
* "validation_groups"={"Default", "my-entity:put"}}, | |
* }, | |
* "put_custom"={ | |
* "method"="PUT", | |
* "path"="/my-entity/{id}/custom", | |
* "validation_groups"={"Default", "my-entity:put_custom"}}, | |
* } | |
* } | |
* ) | |
*/ | |
class MyEntity { | |
public $id; | |
/** | |
* @Assert\NotBlank(groups={"my-entity:post", "my-entity:put"}) | |
* @Assert\Type("string") | |
*/ | |
public $name; | |
/** | |
* @Assert\NotBlank(groups={"my-entity:put_custom"}) | |
* @Assert\Length(min=1, max=3) | |
*/ | |
public $specialValue; | |
public $createdAt; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment