Enhance form logic property resolver and validation UI

- Refactor `shouldBeRequired()` method in FormLogicPropertyResolver for clearer logic and better handling of conditional requirements
- Add comprehensive test cases for dynamic field requirement logic
- Update CustomFieldValidation component with improved UI and guidance for validation setup
- Improve error message and validation rule description in form validation interface
This commit is contained in:
Julien Nahum
2025-02-11 15:05:27 +01:00
parent f5b9b86c16
commit 853760484c
3 changed files with 142 additions and 31 deletions

View File

@@ -107,4 +107,91 @@ it('can validate form logic property resolver', function ($property, $formData,
['93ea3198-353f-440b-8dc9-2ac9a7bee124' => [], '93ea3198-353f-440b-8dc9-2ac9a7bee222' => ['abc']],
false,
],
[
[
'id' => 'text_field',
'name' => 'Required if checked',
'type' => 'text',
'hidden' => false,
'logic' => [
'conditions' => [
'operatorIdentifier' => 'and',
'children' => [
[
'identifier' => 'checkbox',
'value' => [
'operator' => 'is_checked',
'property_meta' => [
'id' => 'checkbox_field',
'type' => 'checkbox'
],
'value' => true
]
]
]
],
'actions' => ['require-answer']
]
],
['checkbox_field' => true],
true
],
[
[
'id' => 'text_field',
'name' => 'Required if checked',
'type' => 'text',
'hidden' => false,
'logic' => [
'conditions' => [
'operatorIdentifier' => 'and',
'children' => [
[
'identifier' => 'checkbox',
'value' => [
'operator' => 'is_checked',
'property_meta' => [
'id' => 'checkbox_field',
'type' => 'checkbox'
],
'value' => true
]
]
]
],
'actions' => ['require-answer']
]
],
['checkbox_field' => false],
false
],
[
[
'id' => 'text_field',
'name' => 'Required if checked',
'type' => 'text',
'hidden' => false,
'logic' => [
'conditions' => [
'operatorIdentifier' => 'and',
'children' => [
[
'identifier' => 'checkbox',
'value' => [
'operator' => 'is_checked',
'property_meta' => [
'id' => 'checkbox_field',
'type' => 'checkbox'
],
'value' => true
]
]
]
],
'actions' => ['require-answer']
]
],
['checkbox_field' => null],
false
]
]);