diff --git a/Classes/Validation/Validator/SettingsValidator.php b/Classes/Validation/Validator/SettingsValidator.php index 112bdc4..c94efff 100644 --- a/Classes/Validation/Validator/SettingsValidator.php +++ b/Classes/Validation/Validator/SettingsValidator.php @@ -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'], diff --git a/Configuration/Testing/Validation.yaml b/Configuration/Testing/Validation.yaml index f9575d2..bc17503 100644 --- a/Configuration/Testing/Validation.yaml +++ b/Configuration/Testing/Validation.yaml @@ -1,18 +1,14 @@ DigiComp\SettingValidator\Tests\Functional\Fixtures\TestObject: - - - property: shouldBeTrue - validator: BooleanValue - options: - expectedValue: true - - - property: shouldBeFalse - validator: BooleanValue - options: - expectedValue: false - + properties: + shouldBeTrue: + BooleanValue: + expectedValue: true + shouldBeFalse: + BooleanValue: + expectedValue: false + Grumble: ~ TrueValidator: - - - validator: BooleanValue - options: - expectedValue: true \ No newline at end of file + self: + BooleanValue: + expectedValue: true diff --git a/Resources/Private/Schema/Validation.schema.yaml b/Resources/Private/Schema/Validation.schema.yaml index b917695..3f96d9d 100644 --- a/Resources/Private/Schema/Validation.schema.yaml +++ b/Resources/Private/Schema/Validation.schema.yaml @@ -1,11 +1,11 @@ type: dictionary additionalProperties: - type: array - items: + type: dictionary + additionalProperties: false + properties: 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 + self: + type: dictionary