DigiComp.SettingValidator/README.md

47 lines
1.3 KiB
Markdown
Raw Normal View History

2015-04-29 17:50:13 +02:00
DigiComp.SettingValidator
-------------------------
This Package allows to configure Validators for your Action-Arguments or domain model properties to be set by a new
Yaml-File in your Configuration directory.
Lets imagine you had this action-method:
2020-03-11 12:00:42 +01:00
/**
* @param Order $order
* @Flow\Validate(type="DigiComp.SettingValidator:Settings")
*/
public function createOrder($order) {...}
2015-04-29 17:50:13 +02:00
Then your Validation.yaml could look like this:
2020-03-11 12:00:42 +01:00
SuperVendor\SuperPackage\Domain\Model\Order:
-
2020-03-11 12:09:37 +01:00
property: price
2020-03-11 12:00:42 +01:00
validator: NumberRange
options:
maximum: 20
minimum: 10
-
validator: SuperVendor.SuperPackage:SomeOtherValidator #validates the complete object
options: []
-
property: customer
validator: DigiComp.SettingValidator:Settings
options:
name: OrderCustomer
2020-03-11 12:09:37 +01:00
2020-03-11 12:00:42 +01:00
OrderCustomer:
-
property: firstName
validator: StringLength
options:
minimum: 3
maximum: 20
2019-06-07 09:02:40 +02:00
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.