NotBlank¶
Validates that a value is not blank, defined as not equal to a blank string
and also not equal to null. To force that a value is simply not equal to
null, see the NotNull constraint.
| Applies to | property or method |
| Options | |
| Class | Symfony\Component\Validator\Constraints\NotBlank |
| Validator | Symfony\Component\Validator\Constraints\NotBlankValidator |
Basic Usage¶
If you wanted to ensure that the firstName property of an Author class
were not blank, you could do the following:
- YAML
properties: firstName: - NotBlank: ~
- Annotations
// src/Acme/BlogBundle/Entity/Author.php use Symfony\Component\Validator\Constraints as Assert; class Author { /** * @Assert\NotBlank() */ protected $firstName; }