2015-04-29 17:50:13 +02:00
|
|
|
DigiComp.SettingValidator
|
|
|
|
-------------------------
|
|
|
|
|
2020-05-04 23:27:47 +02:00
|
|
|
This Package allows configuring Validators for your Action-Arguments or domain model properties to be set by a new
|
2015-04-29 17:50:13 +02:00
|
|
|
Yaml-File in your Configuration directory.
|
|
|
|
|
2020-05-04 23:27:47 +02:00
|
|
|
Let's imagine you had this action-method:
|
2015-04-29 17:50:13 +02:00
|
|
|
|
2020-03-11 12:00:42 +01:00
|
|
|
/**
|
2020-05-14 14:47:33 +02:00
|
|
|
* @Flow\Validate(argumentName="order", type="DigiComp.SettingValidator:Settings")
|
2020-03-11 12:00:42 +01:00
|
|
|
* @param Order $order
|
|
|
|
*/
|
|
|
|
public function createOrder($order) {...}
|
2015-04-29 17:50:13 +02:00
|
|
|
|
|
|
|
Then your Validation.yaml could look like this:
|
|
|
|
|
2020-05-04 23:27:47 +02:00
|
|
|
Vendor\Package\Domain\Model\Order:
|
|
|
|
# validates the complete object
|
|
|
|
self:
|
|
|
|
'Vendor.Package:SomeOtherValidator': []
|
|
|
|
# validates properties of the object
|
|
|
|
properties:
|
|
|
|
price:
|
|
|
|
NumberRange:
|
|
|
|
maximum: 20
|
|
|
|
minimum: 10
|
|
|
|
customer:
|
|
|
|
'DigiComp.SettingValidator:Settings':
|
|
|
|
name: 'OrderCustomer'
|
2020-03-11 12:09:37 +01:00
|
|
|
|
2020-03-11 12:00:42 +01:00
|
|
|
OrderCustomer:
|
2020-05-04 23:27:47 +02:00
|
|
|
properties:
|
|
|
|
firstName:
|
|
|
|
StringLength:
|
|
|
|
minimum: 3
|
|
|
|
maximum: 20
|
2015-04-29 17:50:13 +02:00
|
|
|
|
|
|
|
As you see: Nesting is possible ;) That way you can easily construct flexible structures.
|
|
|
|
|
|
|
|
The SettingsValidator has an optional option: "name" - If you don't give one, it assumes your validation value is an
|
2020-03-11 12:00:42 +01:00
|
|
|
object and searches in Validation.yaml for the FQCN.
|