There are 3 fields, I want to validate so if 1 is available, 2 others are not available and vice versa. It seems that this can be done using Expression Language, but even does not work. While trying this:

this.getOrganization() === \AppBundle\Entity\Organization\Organization 
  • Speech on validation using the Validation component? - Dmitriy Simushev
  • no, validation with Expression symfony.com/doc/current/reference/constraints/Expression.html - Rostislav Prozorovsky
  • Yes, validation with the Validation component. ( Expression constarint - part of the component Validation);) - Dmitriy Simushev

1 answer 1

You can use the following expression:

 (this.getFoo() != null) xor (this.getBar() != null and this.getBaz() != null)