I’ve got an ‘addressClass’ and a ‘shippingAddressClass’. ‘ShippingAdress’ extends ‘Address’ and they both validate identically EXCEPT ‘shippingAddress’ invalidates when a PO Box is detected. While a PO box is a perfectly valid billing address, UPS doesn’t ship to them.
Hypothetically, What’s the SF2 Best Practice for validating Bird which extends Animal?
Should we duplicate the .yml which we used to validate Animal? Essentially giving us two fairly identical sections (see below). In this case, the getters are a little different from Animal to Bird but the properties require pretty identical validation rules.
Acme\BlogBundle\Entity\Animal:
properties:
name:
- NotBlank: ~
getters:
isAnimal:
- "True"
Acme\BlogBundle\Entity\Bird:
properties:
name:
- NotBlank: ~
getters:
isAnimal:
- "True"
isBird
- "True"
Validator Service is smart and validates against the constraints of the origin classes. So in my
Animal,Birdexample, we would only need: