← All changes
|
src/Framework/FieldsAPI/Actions/CreateValidatorFromForm.php
+4
-1
2.30.0
→
4.16.9
View file →
| @@ -9,8 +9,9 @@ | ||
| 9 | 9 | |
| 10 | 10 | class CreateValidatorFromForm |
| 11 | 11 | { |
| 12 | 12 | /** |
| 13 | + * @since 3.0.0 Update validation rules with optional as default. | |
| 13 | 14 | * @since 2.24.0 |
| 14 | 15 | */ |
| 15 | 16 | public function __invoke(Form $form, array $values): Validator |
| 16 | 17 | { |
| @@ -17,9 +18,11 @@ | ||
| 17 | 18 | $labels = []; |
| 18 | 19 | $rules = []; |
| 19 | 20 | |
| 20 | 21 | foreach ($form->getFields() as $field) { |
| 21 | - $rules[$field->getName()] = $field->getValidationRules(); | |
| 22 | + $rules[$field->getName()] = (new UpdateValidationRulesWithOptionalAsDefault())( | |
| 23 | + $field->getValidationRules() | |
| 24 | + ); | |
| 22 | 25 | |
| 23 | 26 | if (method_exists($field, 'getLabel')) { |
| 24 | 27 | $labels[$field->getName()] = $field->getLabel(); |
| 25 | 28 | } |