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) {
|
foreach ($config as $validatorConfig) {
|
||||||
$validator = $this->validatorResolver->createValidator(
|
$validator = $this->validatorResolver->createValidator(
|
||||||
$validatorConfig['validator'],
|
$validatorConfig['validator'],
|
||||||
|
|
|
@ -1,18 +1,14 @@
|
||||||
DigiComp\SettingValidator\Tests\Functional\Fixtures\TestObject:
|
DigiComp\SettingValidator\Tests\Functional\Fixtures\TestObject:
|
||||||
-
|
properties:
|
||||||
property: shouldBeTrue
|
shouldBeTrue:
|
||||||
validator: BooleanValue
|
BooleanValue:
|
||||||
options:
|
expectedValue: true
|
||||||
expectedValue: true
|
shouldBeFalse:
|
||||||
-
|
BooleanValue:
|
||||||
property: shouldBeFalse
|
expectedValue: false
|
||||||
validator: BooleanValue
|
Grumble: ~
|
||||||
options:
|
|
||||||
expectedValue: false
|
|
||||||
|
|
||||||
|
|
||||||
TrueValidator:
|
TrueValidator:
|
||||||
-
|
self:
|
||||||
validator: BooleanValue
|
BooleanValue:
|
||||||
options:
|
|
||||||
expectedValue: true
|
expectedValue: true
|
|
@ -1,11 +1,11 @@
|
||||||
type: dictionary
|
type: dictionary
|
||||||
additionalProperties:
|
additionalProperties:
|
||||||
type: array
|
type: dictionary
|
||||||
items:
|
additionalProperties: false
|
||||||
|
properties:
|
||||||
type: dictionary
|
type: dictionary
|
||||||
additionalProperties: false
|
additionalProperties: false
|
||||||
# This validation sadly only hits the first level of validation, and options are not coverable with current validator
|
|
||||||
properties:
|
properties:
|
||||||
validator: {type: string, required: true}
|
type: dictionary
|
||||||
options: {type: dictionary, required: true}
|
self:
|
||||||
property: {type: string, required: false}
|
type: dictionary
|
||||||
|
|
Loading…
Reference in a new issue