Download the PHP package fluoresce/validate-embedded without Composer
On this page you can find all versions of the php package fluoresce/validate-embedded. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download fluoresce/validate-embedded
More information about fluoresce/validate-embedded
Files in fluoresce/validate-embedded
Package validate-embedded
Short Description Constraint enabling group-based validation of embedded objects with the Symfony Validator Component.
License MIT
Homepage https://github.com/fluoresceco/validate-embedded
Informations about the package validate-embedded
Validate Embedded
This library provides the Validate
constraint for the
Symfony Validator Component.
This constraint behaves similar to the built-in Valid
constraint, but respects
the groups
option. Additionally, it adds an option to specify the validation
groups to target on the embedded object(s).
Installation
Open a command console, enter your project directory and execute the following command to download the latest stable version of this bundle:
This command requires you to have Composer installed globally, as explained in the installation chapter of the Composer documentation.
Documentation
The following examples assume you are using the full Symfony framework, though this package can be used in any project that has the Symfony Validator Component available
Basic Usage
This example shows an Author
which has a collection of Book
s. When
validation is run for group1
on Author
, it will cascade to all embedded
Book
instances.
The behaviour here is slightly different to the standard Valid
constraint, as
validation of the Book
instances is run with the default group.
Specifying Embedded Validation Groups
Imagine we want to specify different validation groups to be run on the Book
instances. We can target these by specifying them in the Validate
annotation.
Now whenever an Author
instance is validated, the embedded Book
s will be
validated with validation group bookgroup1
.
Combining All Options
This example combines behaviour from the previous ones to show how it operates together.