Null¶
Validates that a value is exactly equal to null
. To force that a property
is simply blank (blank string or null
), see the Blank
constraint. To ensure that a property is not null, see NotNull.
Applies to | property or method |
Options | |
Class | Symfony\Component\Validator\Constraints\Null |
Validator | Symfony\Component\Validator\Constraints\NullValidator |
Basic Usage¶
If, for some reason, you wanted to ensure that the firstName
property
of an Author
class exactly equal to null
, you could do the following:
- YAML
# src/Acme/BlogBundle/Resources/config/validation.yml Acme\BlogBundle\Entity\Author: properties: firstName: - Null: ~
- Annotations
// src/Acme/BlogBundle/Entity/Author.php namespace Acme\BlogBundle\Entity; use Symfony\Component\Validator\Constraints as Assert; class Author { /** * @Assert\Null() */ protected $firstName; }