TASK: Completely changing the layout of Validation.yaml
This commit is contained in:
parent
40fc82e515
commit
9a055a2f77
3 changed files with 42 additions and 22 deletions
|
@ -75,7 +75,31 @@ class SettingsValidator extends AbstractValidator
|
|||
);
|
||||
}
|
||||
|
||||
$config = &$this->validations[$name];
|
||||
$config = [];
|
||||
if (isset($this->validations[$name]['self'])) {
|
||||
foreach ($this->validations[$name]['self'] as $validator => &$validation) {
|
||||
if (is_null($validation)) {
|
||||
continue;
|
||||
}
|
||||
$newValidation['options'] = $validation;
|
||||
$newValidation['validator'] = $validator;
|
||||
$config[] = $newValidation;
|
||||
}
|
||||
}
|
||||
if (isset($this->validations[$name]['properties'])) {
|
||||
foreach ($this->validations[$name]['properties'] as $propertyName => &$validation) {
|
||||
foreach ($validation as $validator => &$options) {
|
||||
if (is_null($options)) {
|
||||
continue;
|
||||
}
|
||||
$newValidation['property'] = $propertyName;
|
||||
$newValidation['validator'] = $validator;
|
||||
$newValidation['options'] = $options;
|
||||
$config[] = $newValidation;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
foreach ($config as $validatorConfig) {
|
||||
$validator = $this->validatorResolver->createValidator(
|
||||
$validatorConfig['validator'],
|
||||
|
|
|
@ -1,18 +1,14 @@
|
|||
DigiComp\SettingValidator\Tests\Functional\Fixtures\TestObject:
|
||||
-
|
||||
property: shouldBeTrue
|
||||
validator: BooleanValue
|
||||
options:
|
||||
properties:
|
||||
shouldBeTrue:
|
||||
BooleanValue:
|
||||
expectedValue: true
|
||||
-
|
||||
property: shouldBeFalse
|
||||
validator: BooleanValue
|
||||
options:
|
||||
shouldBeFalse:
|
||||
BooleanValue:
|
||||
expectedValue: false
|
||||
|
||||
Grumble: ~
|
||||
|
||||
TrueValidator:
|
||||
-
|
||||
validator: BooleanValue
|
||||
options:
|
||||
self:
|
||||
BooleanValue:
|
||||
expectedValue: true
|
|
@ -1,11 +1,11 @@
|
|||
type: dictionary
|
||||
additionalProperties:
|
||||
type: array
|
||||
items:
|
||||
type: dictionary
|
||||
additionalProperties: false
|
||||
# This validation sadly only hits the first level of validation, and options are not coverable with current validator
|
||||
properties:
|
||||
validator: {type: string, required: true}
|
||||
options: {type: dictionary, required: true}
|
||||
property: {type: string, required: false}
|
||||
type: dictionary
|
||||
additionalProperties: false
|
||||
properties:
|
||||
type: dictionary
|
||||
self:
|
||||
type: dictionary
|
||||
|
|
Loading…
Reference in a new issue