Skip to content

Validation and storage

phil/address-bundle

ValidAddress

#[ValidAddress]
public ?Address $address = null;

An Address is complete and right for its country; each violation is on its field's path, address.postalCode. null is valid.

CodeMessage
MISSING_ERRORThis value is required in an address of this country.
UNUSED_ERRORThis value is not part of an address of this country.
INVALID_POSTAL_CODE_ERRORThis postal code is not one of this country or region.
UNKNOWN_SUBDIVISION_ERRORThis place is not one of this country.

phil_address

With DoctrineBundle, the column type phil_address: an Address in one JSON column, as AddressArray writes it.

#[ORM\Column(type: 'phil_address', nullable: true)]
private ?Address $address = null;

A value that is not an Address is refused on writing; a stored text that is no JSON, nested deeper than an address, or no address, on reading.