mirror of
https://github.com/alrayyes/wiki.git
synced 2024-11-21 19:16:23 +00:00
852 B
852 B
date | id | title |
---|---|---|
2020-11-13 | 942ca5cd-5ca6-4ec9-9dd6-652a0b791245 | Type Constraint |
Description
Validates that a given value is of a specific type. This type can be any of the valid PHP types1, any of the PHP ctype functions2 (e.g. alnum, alpha, digit, etc.) and also the FQCN of any class
Syntax
// src/Entity/Author.php
namespace App\Entity;
use Symfony\Component\Validator\Constraints as Assert;
class Author
{
/**
* @Assert\Type("Ramsey\Uuid\UuidInterface")
*/
protected $id;
/**
* @Assert\Type("string")
*/
protected $firstName;
// ...
}