For each user I have name, surname and phone numbers. I need to validate these fields in my validation.yml to check if they are not empty. For name and surname validation I have this and it is working very well:
RFQ\IronilBundle\Entity\User:
properties:
name:
- NotBlank: { groups: [not_empty] }
surname:
- NotBlank: { groups: [not_empty] }
Problem is there that I can't to find any example in documentation how to validate phone field, because each user can have more than one phone number. My entity for phone is:
/**
* @ORM\Column(type="array", nullable=true)
* @Assert\NotNull()
*/
protected $phone;
and upon registering I insert in database empty array value (I need this to show empty phone field in my edit action):
public function __construct() {
parent::__construct();
$this->phone = array('');
}
Thank you!
Callbackvalidator that would call an entity method that does the checks.