mirror of
https://github.com/alrayyes/wiki.git
synced 2024-11-29 06:26:22 +00:00
788 B
788 B
id | title |
---|---|
c7132269-2084-4d87-9888-0f860db29aaf | Automatic Validation Based on Doctrine Mapping |
Description
From Symfony 4.3, Symfony introduces automatic validation based on Doctrine mapping.
Examples
use Doctrine\ORM\Mapping as ORM;
/** @ORM\Entity */
class SomeEntity
{
// ...
/** @ORM\Column(length=4) */
public $pinCode;
}
$entity = new SomeEntity();
$entity->pinCode = '1234567890';
$violationList = $validator->validate($entity);
$violationList = $validator->validate($entity);
var_dump((string) $violationList);
// Object(App\Entity\SomeEntity).columnLength:\n
// This value is too long. It should have 4 characters or less.
// (code d94b19cc-114f-4f44-9cc4-4138e80a87b9)\n