@ukhomeoffice/cop-react-form-renderer 6.0.6-peter → 6.7.0-alpha
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/components/CheckYourAnswers/Answer.js +12 -12
- package/dist/components/CheckYourAnswers/Answer.test.js +92 -127
- package/dist/components/CheckYourAnswers/CheckYourAnswers.js +101 -131
- package/dist/components/CheckYourAnswers/CheckYourAnswers.scss +2 -2
- package/dist/components/CheckYourAnswers/CheckYourAnswers.test.js +463 -769
- package/dist/components/CollectionPage/CollectionPage.js +75 -59
- package/dist/components/CollectionPage/CollectionPage.test.js +316 -366
- package/dist/components/CollectionSummary/BannerStrip.js +15 -14
- package/dist/components/CollectionSummary/BannerStrip.scss +2 -2
- package/dist/components/CollectionSummary/BannerStrip.test.js +98 -59
- package/dist/components/CollectionSummary/CollectionSummary.js +144 -135
- package/dist/components/CollectionSummary/CollectionSummary.scss +1 -1
- package/dist/components/CollectionSummary/CollectionSummary.test.js +167 -197
- package/dist/components/CollectionSummary/Confirmation.js +14 -12
- package/dist/components/CollectionSummary/Confirmation.scss +1 -1
- package/dist/components/CollectionSummary/Confirmation.test.js +68 -63
- package/dist/components/CollectionSummary/RenderListView.js +54 -56
- package/dist/components/CollectionSummary/RenderListView.scss +10 -1
- package/dist/components/CollectionSummary/RenderListView.test.js +89 -78
- package/dist/components/CollectionSummary/SummaryCard.js +135 -145
- package/dist/components/CollectionSummary/SummaryCard.scss +2 -1
- package/dist/components/CollectionSummary/SummaryCard.test.js +943 -932
- package/dist/components/CollectionSummary/SummaryCardDetails.js +120 -62
- package/dist/components/CollectionSummary/SummaryCardDetails.scss +43 -6
- package/dist/components/CollectionSummary/SummaryCardDetails.test.js +261 -120
- package/dist/components/CollectionSummary/SummaryCardValidationContext.js +38 -33
- package/dist/components/CollectionSummary/SummaryCardValidationContext.test.js +62 -73
- package/dist/components/FormComponent/Collection.js +81 -108
- package/dist/components/FormComponent/Collection.test.js +909 -943
- package/dist/components/FormComponent/Container.js +40 -38
- package/dist/components/FormComponent/Container.test.js +314 -345
- package/dist/components/FormComponent/FormComponent.js +80 -71
- package/dist/components/FormComponent/FormComponent.test.js +353 -414
- package/dist/components/FormComponent/helpers/addLabel.js +4 -7
- package/dist/components/FormComponent/helpers/getComponentDisabled.js +1 -1
- package/dist/components/FormComponent/helpers/getComponentDisabled.test.js +7 -7
- package/dist/components/FormComponent/helpers/getComponentError.js +3 -5
- package/dist/components/FormComponent/helpers/getComponentError.test.js +14 -14
- package/dist/components/FormComponent/helpers/getComponentFieldSet.js +3 -4
- package/dist/components/FormComponent/helpers/getComponentFieldSet.test.js +6 -6
- package/dist/components/FormComponent/helpers/index.js +4 -4
- package/dist/components/FormPage/FormPage.js +65 -80
- package/dist/components/FormPage/FormPage.scss +1 -1
- package/dist/components/FormPage/FormPage.test.js +127 -163
- package/dist/components/FormRenderer/FormRenderer.js +150 -183
- package/dist/components/FormRenderer/FormRenderer.scss +1 -1
- package/dist/components/FormRenderer/FormRenderer.test.js +730 -1115
- package/dist/components/FormRenderer/handlers/cyaAction.js +2 -2
- package/dist/components/FormRenderer/handlers/getPageId.js +1 -3
- package/dist/components/FormRenderer/handlers/getPageId.test.js +14 -14
- package/dist/components/FormRenderer/handlers/handlers.test.js +32 -32
- package/dist/components/FormRenderer/handlers/index.js +1 -1
- package/dist/components/FormRenderer/handlers/navigate.js +3 -3
- package/dist/components/FormRenderer/handlers/submissionError.js +1 -1
- package/dist/components/FormRenderer/helpers/canActionProceed.js +1 -1
- package/dist/components/FormRenderer/helpers/canActionProceed.test.js +15 -15
- package/dist/components/FormRenderer/helpers/canCYASubmit.js +1 -3
- package/dist/components/FormRenderer/helpers/canCYASubmit.test.js +16 -20
- package/dist/components/FormRenderer/helpers/cleanHiddenNestedData.js +17 -22
- package/dist/components/FormRenderer/helpers/cleanHiddenNestedData.test.js +16 -16
- package/dist/components/FormRenderer/helpers/getCYA.js +3 -5
- package/dist/components/FormRenderer/helpers/getCYA.test.js +11 -11
- package/dist/components/FormRenderer/helpers/getFormState.js +5 -7
- package/dist/components/FormRenderer/helpers/getFormState.test.js +10 -10
- package/dist/components/FormRenderer/helpers/getNextPageId.js +13 -24
- package/dist/components/FormRenderer/helpers/getNextPageId.test.js +67 -67
- package/dist/components/FormRenderer/helpers/getPage.js +2 -4
- package/dist/components/FormRenderer/helpers/getPage.test.js +11 -11
- package/dist/components/FormRenderer/helpers/getRelevantPages.js +7 -9
- package/dist/components/FormRenderer/helpers/getRelevantPages.test.js +14 -14
- package/dist/components/FormRenderer/helpers/getSubmissionStatus.js +5 -5
- package/dist/components/FormRenderer/helpers/getSubmissionStatus.test.js +103 -97
- package/dist/components/FormRenderer/helpers/getUpdatedSectionStates.js +62 -60
- package/dist/components/FormRenderer/helpers/getUpdatedSectionStates.test.js +71 -78
- package/dist/components/FormRenderer/helpers/index.js +2 -4
- package/dist/components/FormRenderer/onCYAAction.js +59 -51
- package/dist/components/FormRenderer/onCYAAction.test.js +164 -152
- package/dist/components/FormRenderer/onPageAction.js +50 -48
- package/dist/components/FormRenderer/onPageAction.test.js +241 -217
- package/dist/components/FormRenderer/onTaskAction.js +9 -13
- package/dist/components/FormRenderer/onTaskAction.test.js +93 -88
- package/dist/components/PageActions/ActionButton.js +12 -15
- package/dist/components/PageActions/ActionButton.test.js +56 -78
- package/dist/components/PageActions/PageActions.js +10 -10
- package/dist/components/PageActions/PageActions.test.js +86 -115
- package/dist/components/SummaryList/GroupAction.js +9 -17
- package/dist/components/SummaryList/GroupAction.test.js +37 -33
- package/dist/components/SummaryList/RowAction.js +11 -16
- package/dist/components/SummaryList/RowAction.test.js +37 -33
- package/dist/components/SummaryList/SummaryList.js +21 -26
- package/dist/components/SummaryList/SummaryList.scss +2 -2
- package/dist/components/SummaryList/SummaryList.test.js +143 -166
- package/dist/components/SummaryList/SummaryListHeadingRow.js +6 -4
- package/dist/components/SummaryList/SummaryListRow.js +6 -4
- package/dist/components/SummaryList/SummaryListTitleRow.js +5 -3
- package/dist/components/SummaryList/helpers/getGroupActionAttributes.js +3 -5
- package/dist/components/SummaryList/helpers/getGroupActionAttributes.test.js +22 -22
- package/dist/components/SummaryList/helpers/getRowActionAttributes.js +3 -5
- package/dist/components/SummaryList/helpers/getRowActionAttributes.test.js +22 -22
- package/dist/components/SummaryList/helpers/index.js +1 -1
- package/dist/components/TaskList/Task.js +19 -29
- package/dist/components/TaskList/Task.test.js +83 -76
- package/dist/components/TaskList/TaskList.js +45 -71
- package/dist/components/TaskList/TaskList.scss +1 -1
- package/dist/components/TaskList/TaskList.test.js +113 -111
- package/dist/components/TaskList/TaskState.js +7 -5
- package/dist/components/TaskList/TaskState.test.js +52 -45
- package/dist/components/index.js +7 -7
- package/dist/context/HooksContext/HooksContext.js +57 -80
- package/dist/context/HooksContext/HooksContext.test.js +26 -35
- package/dist/context/HooksContext/index.js +3 -4
- package/dist/context/ValidationContext/ValidationContext.js +65 -72
- package/dist/context/ValidationContext/ValidationContext.test.js +58 -61
- package/dist/context/ValidationContext/index.js +3 -4
- package/dist/context/index.js +2 -2
- package/dist/hooks/index.js +9 -10
- package/dist/hooks/useAxios.js +14 -40
- package/dist/hooks/useGetRequest.js +61 -97
- package/dist/hooks/useHooks.js +1 -3
- package/dist/hooks/useRefData.js +27 -40
- package/dist/hooks/useValidation.js +1 -3
- package/dist/index.js +13 -14
- package/dist/models/CollectionLabels.js +1 -1
- package/dist/models/ComponentTypes.js +25 -25
- package/dist/models/EventTypes.js +4 -4
- package/dist/models/FormPages.js +4 -4
- package/dist/models/FormTypes.js +8 -8
- package/dist/models/HubFormats.js +3 -3
- package/dist/models/PageAction.js +44 -38
- package/dist/models/TaskStates.js +29 -28
- package/dist/models/index.js +9 -9
- package/dist/setupTests.js +30 -31
- package/dist/utils/CheckYourAnswers/getCYAAction.js +5 -5
- package/dist/utils/CheckYourAnswers/getCYAAction.test.js +52 -54
- package/dist/utils/CheckYourAnswers/getCYACollectionChangeAction.js +15 -25
- package/dist/utils/CheckYourAnswers/getCYACollectionChangeAction.test.js +33 -35
- package/dist/utils/CheckYourAnswers/getCYACollectionDeleteAction.js +17 -31
- package/dist/utils/CheckYourAnswers/getCYACollectionDeleteAction.test.js +42 -44
- package/dist/utils/CheckYourAnswers/getCYARow.js +6 -6
- package/dist/utils/CheckYourAnswers/getCYARow.test.js +86 -86
- package/dist/utils/CheckYourAnswers/getCYARowForGroup.js +18 -24
- package/dist/utils/CheckYourAnswers/getCYARowForGroup.test.js +15 -16
- package/dist/utils/CheckYourAnswers/getCYARowsForCollection.js +33 -36
- package/dist/utils/CheckYourAnswers/getCYARowsForCollection.test.js +58 -61
- package/dist/utils/CheckYourAnswers/getCYARowsForCollectionPage.js +83 -89
- package/dist/utils/CheckYourAnswers/getCYARowsForCollectionPage.test.js +164 -138
- package/dist/utils/CheckYourAnswers/getCYARowsForContainer.js +25 -20
- package/dist/utils/CheckYourAnswers/getCYARowsForContainer.test.js +103 -97
- package/dist/utils/CheckYourAnswers/getCYARowsForPage.js +13 -18
- package/dist/utils/CheckYourAnswers/getCYARowsForPage.test.js +70 -76
- package/dist/utils/CheckYourAnswers/getComponentRowForCYA.js +11 -11
- package/dist/utils/CheckYourAnswers/getComponentRowForCYA.test.js +7 -7
- package/dist/utils/CheckYourAnswers/index.js +1 -1
- package/dist/utils/CheckYourAnswers/showComponentCYA.js +4 -5
- package/dist/utils/CheckYourAnswers/showComponentCYA.test.js +29 -24
- package/dist/utils/CollectionPage/addCollectionPageEntry.js +3 -4
- package/dist/utils/CollectionPage/addCollectionPageEntry.test.js +7 -27
- package/dist/utils/CollectionPage/duplicateCollectionPageActiveEntry.js +2 -2
- package/dist/utils/CollectionPage/duplicateCollectionPageActiveEntry.test.js +17 -18
- package/dist/utils/CollectionPage/duplicateCollectionPageEntry.js +29 -19
- package/dist/utils/CollectionPage/duplicateCollectionPageEntry.test.js +66 -22
- package/dist/utils/CollectionPage/getCollectionPageActiveId.js +2 -2
- package/dist/utils/CollectionPage/getCollectionPageActiveId.test.js +10 -10
- package/dist/utils/CollectionPage/getCollectionPageActiveIndex.js +7 -11
- package/dist/utils/CollectionPage/getCollectionPageActiveIndex.test.js +22 -22
- package/dist/utils/CollectionPage/getCollectionPageData.js +8 -12
- package/dist/utils/CollectionPage/getCollectionPageData.test.js +19 -19
- package/dist/utils/CollectionPage/getErrorsForCollection.js +55 -0
- package/dist/utils/CollectionPage/getErrorsForCollection.test.js +153 -0
- package/dist/utils/CollectionPage/getQuickEditPage.js +37 -23
- package/dist/utils/CollectionPage/getQuickEditPage.test.js +26 -45
- package/dist/utils/CollectionPage/index.js +3 -1
- package/dist/utils/CollectionPage/mergeCollectionPages.js +31 -35
- package/dist/utils/CollectionPage/mergeCollectionPages.test.js +20 -20
- package/dist/utils/CollectionPage/removeCollectionPageEntry.js +4 -6
- package/dist/utils/CollectionPage/removeCollectionPageEntry.test.js +10 -10
- package/dist/utils/CollectionPage/setCollectionPageData.js +16 -17
- package/dist/utils/CollectionPage/setCollectionPageData.test.js +38 -20
- package/dist/utils/Component/addShowWhen.js +4 -8
- package/dist/utils/Component/addShowWhen.test.js +37 -37
- package/dist/utils/Component/applyToComponentTree.js +18 -18
- package/dist/utils/Component/applyToComponentTree.test.js +27 -32
- package/dist/utils/Component/cleanAttributes.js +10 -13
- package/dist/utils/Component/cleanAttributes.test.js +17 -18
- package/dist/utils/Component/elevateNestedComponents.js +5 -5
- package/dist/utils/Component/elevateNestedComponents.test.js +30 -30
- package/dist/utils/Component/getComponent.js +88 -94
- package/dist/utils/Component/getComponentTests/getComponent.autocomplete.test.js +18 -17
- package/dist/utils/Component/getComponentTests/getComponent.calculation.test.js +46 -59
- package/dist/utils/Component/getComponentTests/getComponent.checkboxes.test.js +39 -48
- package/dist/utils/Component/getComponentTests/getComponent.date.test.js +23 -33
- package/dist/utils/Component/getComponentTests/getComponent.details.test.js +20 -18
- package/dist/utils/Component/getComponentTests/getComponent.email.test.js +17 -22
- package/dist/utils/Component/getComponentTests/getComponent.file.test.js +20 -25
- package/dist/utils/Component/getComponentTests/getComponent.heading.test.js +10 -9
- package/dist/utils/Component/getComponentTests/getComponent.html.test.js +17 -15
- package/dist/utils/Component/getComponentTests/getComponent.insetText.test.js +9 -8
- package/dist/utils/Component/getComponentTests/getComponent.list.test.js +17 -15
- package/dist/utils/Component/getComponentTests/getComponent.multifile.test.js +22 -26
- package/dist/utils/Component/getComponentTests/getComponent.nested.test.js +155 -175
- package/dist/utils/Component/getComponentTests/getComponent.paragraph.test.js +17 -15
- package/dist/utils/Component/getComponentTests/getComponent.phoneNumber.test.js +17 -22
- package/dist/utils/Component/getComponentTests/getComponent.radios.test.js +57 -72
- package/dist/utils/Component/getComponentTests/getComponent.select.test.js +17 -22
- package/dist/utils/Component/getComponentTests/getComponent.text.test.js +17 -22
- package/dist/utils/Component/getComponentTests/getComponent.textArea.test.js +31 -38
- package/dist/utils/Component/getComponentTests/getComponent.time.test.js +20 -29
- package/dist/utils/Component/getComponentTests/getComponent.unknown.test.js +2 -2
- package/dist/utils/Component/getComponentTests/getComponent.warningText.test.js +9 -8
- package/dist/utils/Component/getDefaultValue.js +6 -8
- package/dist/utils/Component/getDefaultValue.test.js +12 -12
- package/dist/utils/Component/getDefaultValueFromConfig.js +22 -21
- package/dist/utils/Component/getDefaultValueFromConfig.test.js +31 -31
- package/dist/utils/Component/index.js +1 -1
- package/dist/utils/Component/isEditable.js +2 -4
- package/dist/utils/Component/isEditable.test.js +14 -15
- package/dist/utils/Component/optionIsSelected.js +1 -1
- package/dist/utils/Component/optionIsSelected.test.js +9 -9
- package/dist/utils/Component/setupContainerComponentsPath.js +27 -29
- package/dist/utils/Component/setupContainerComponentsPath.test.js +11 -11
- package/dist/utils/Component/showComponent.js +1 -1
- package/dist/utils/Component/showComponent.test.js +28 -28
- package/dist/utils/Component/wrapInFormGroup.js +2 -2
- package/dist/utils/Condition/index.js +1 -1
- package/dist/utils/Condition/meetsAllConditions.js +8 -8
- package/dist/utils/Condition/meetsAllConditions.test.js +20 -20
- package/dist/utils/Condition/meetsCondition.js +28 -19
- package/dist/utils/Condition/meetsCondition.test.js +476 -376
- package/dist/utils/Condition/meetsOneCondition.js +5 -5
- package/dist/utils/Condition/meetsOneCondition.test.js +16 -16
- package/dist/utils/Condition/setupConditions.js +13 -18
- package/dist/utils/Condition/setupConditions.test.js +7 -7
- package/dist/utils/Container/getEditableComponents.js +3 -5
- package/dist/utils/Container/getEditableComponents.test.js +43 -45
- package/dist/utils/Container/index.js +1 -1
- package/dist/utils/Container/setupNesting.js +16 -20
- package/dist/utils/Container/setupNesting.test.js +27 -30
- package/dist/utils/Container/showContainer.js +3 -7
- package/dist/utils/Container/showContainer.test.js +30 -30
- package/dist/utils/Data/applyFormula.js +38 -48
- package/dist/utils/Data/applyFormula.test.js +20 -20
- package/dist/utils/Data/getAutocompleteSource.js +18 -26
- package/dist/utils/Data/getAutocompleteSource.test.js +80 -86
- package/dist/utils/Data/getDataPath.js +18 -28
- package/dist/utils/Data/getDataPath.test.js +12 -12
- package/dist/utils/Data/getOptions.js +29 -25
- package/dist/utils/Data/getOptions.test.js +93 -20
- package/dist/utils/Data/getSourceData.js +6 -19
- package/dist/utils/Data/getSourceData.test.js +84 -80
- package/dist/utils/Data/index.js +1 -1
- package/dist/utils/Data/nestInRefdataOptions.js +42 -0
- package/dist/utils/Data/nestInRefdataOptions.test.js +236 -0
- package/dist/utils/Data/refDataToOptions.js +10 -13
- package/dist/utils/Data/refDataToOptions.test.js +19 -19
- package/dist/utils/Data/setDataItem.js +7 -8
- package/dist/utils/Data/setDataItem.test.js +37 -37
- package/dist/utils/Data/setupFormData.js +13 -21
- package/dist/utils/Data/setupFormData.test.js +51 -50
- package/dist/utils/Data/setupRefDataUrlForComponent.js +20 -26
- package/dist/utils/Data/setupRefDataUrlForComponent.test.js +24 -24
- package/dist/utils/FormPage/applyConditionalProperties.js +5 -9
- package/dist/utils/FormPage/applyConditionalProperties.test.js +15 -18
- package/dist/utils/FormPage/getConditionalText.js +3 -3
- package/dist/utils/FormPage/getConditionalText.test.js +29 -29
- package/dist/utils/FormPage/getFormPage.js +15 -16
- package/dist/utils/FormPage/getFormPage.test.js +47 -46
- package/dist/utils/FormPage/getFormPages.js +7 -12
- package/dist/utils/FormPage/getFormPages.test.js +20 -23
- package/dist/utils/FormPage/getPageActions.js +9 -15
- package/dist/utils/FormPage/getPageActions.test.js +32 -32
- package/dist/utils/FormPage/getParagraphFromText.js +5 -7
- package/dist/utils/FormPage/getParagraphFromText.test.js +6 -6
- package/dist/utils/FormPage/index.js +2 -4
- package/dist/utils/FormPage/showFormPage.js +3 -7
- package/dist/utils/FormPage/showFormPage.test.js +32 -32
- package/dist/utils/FormPage/showFormPageCYA.js +1 -1
- package/dist/utils/FormPage/showFormPageCYA.test.js +8 -8
- package/dist/utils/FormPage/useComponent.js +21 -28
- package/dist/utils/FormPage/useComponent.test.js +77 -79
- package/dist/utils/Format/formatData.js +1 -1
- package/dist/utils/Format/formatData.test.js +18 -18
- package/dist/utils/Format/formatDataForComponent.js +5 -6
- package/dist/utils/Format/formatDataForComponent.test.js +50 -78
- package/dist/utils/Format/formatDataForForm.js +6 -8
- package/dist/utils/Format/formatDataForForm.test.js +13 -16
- package/dist/utils/Format/formatDataForPage.js +4 -5
- package/dist/utils/Format/formatDataForPage.test.js +20 -25
- package/dist/utils/Format/index.js +1 -1
- package/dist/utils/Hub/getFormHub.js +1 -1
- package/dist/utils/Hub/getFormHub.test.js +28 -31
- package/dist/utils/Hub/index.js +1 -1
- package/dist/utils/Meta/constants.js +2 -2
- package/dist/utils/Meta/documents/getDocuments.js +1 -1
- package/dist/utils/Meta/documents/getDocuments.test.js +24 -16
- package/dist/utils/Meta/documents/index.js +1 -1
- package/dist/utils/Meta/documents/setDocumentsForField.js +14 -16
- package/dist/utils/Meta/documents/setDocumentsForField.test.js +68 -34
- package/dist/utils/Meta/index.js +1 -1
- package/dist/utils/Operate/checkValueIsTruthy.js +2 -2
- package/dist/utils/Operate/checkValueIsTruthy.test.js +16 -16
- package/dist/utils/Operate/getFirstOf.js +5 -5
- package/dist/utils/Operate/getFirstOf.test.js +31 -31
- package/dist/utils/Operate/getIndexOfMatchingValueIn.js +10 -10
- package/dist/utils/Operate/getIndexOfMatchingValueIn.test.js +46 -52
- package/dist/utils/Operate/index.js +1 -1
- package/dist/utils/Operate/persistValueInFormData.js +3 -3
- package/dist/utils/Operate/persistValueInFormData.test.js +22 -20
- package/dist/utils/Operate/runPageOperations.js +7 -7
- package/dist/utils/Operate/runPageOperations.test.js +35 -36
- package/dist/utils/Operate/setValueInFormData.js +2 -2
- package/dist/utils/Operate/setValueInFormData.test.js +16 -16
- package/dist/utils/Operate/shouldRun.js +6 -6
- package/dist/utils/Operate/shouldRun.test.js +21 -27
- package/dist/utils/Validate/additional/conditionallyRequired.js +4 -4
- package/dist/utils/Validate/additional/conditionallyRequired.test.js +18 -18
- package/dist/utils/Validate/additional/index.js +6 -6
- package/dist/utils/Validate/additional/index.test.js +12 -12
- package/dist/utils/Validate/additional/mustBeAfter.js +2 -2
- package/dist/utils/Validate/additional/mustBeAfter.test.js +40 -40
- package/dist/utils/Validate/additional/mustBeBefore.js +2 -2
- package/dist/utils/Validate/additional/mustBeBefore.test.js +28 -28
- package/dist/utils/Validate/additional/mustBeEarlierDateTime.js +7 -11
- package/dist/utils/Validate/additional/mustBeEarlierDateTime.test.js +37 -41
- package/dist/utils/Validate/additional/mustBeGreaterThan.js +2 -2
- package/dist/utils/Validate/additional/mustBeGreaterThan.test.js +18 -18
- package/dist/utils/Validate/additional/mustBeInTheFuture.js +2 -2
- package/dist/utils/Validate/additional/mustBeInTheFuture.test.js +12 -12
- package/dist/utils/Validate/additional/mustBeInThePast.js +3 -3
- package/dist/utils/Validate/additional/mustBeInThePast.test.js +12 -12
- package/dist/utils/Validate/additional/mustBeLessThan.js +2 -2
- package/dist/utils/Validate/additional/mustBeLessThan.test.js +17 -17
- package/dist/utils/Validate/additional/mustBeLongerThan.js +1 -1
- package/dist/utils/Validate/additional/mustBeLongerThan.test.js +16 -16
- package/dist/utils/Validate/additional/mustBeNumbersOnly.js +2 -2
- package/dist/utils/Validate/additional/mustBeNumbersOnly.test.js +20 -20
- package/dist/utils/Validate/additional/mustBeShorterThan.js +1 -1
- package/dist/utils/Validate/additional/mustBeShorterThan.test.js +16 -16
- package/dist/utils/Validate/additional/mustBeUniqueInCollection.js +8 -4
- package/dist/utils/Validate/additional/mustBeUniqueInCollection.test.js +64 -32
- package/dist/utils/Validate/additional/mustEnterAtLeastOne.js +2 -2
- package/dist/utils/Validate/additional/mustEnterAtLeastOne.test.js +14 -16
- package/dist/utils/Validate/additional/mustHaveLessThanDecimalPlaces.js +1 -1
- package/dist/utils/Validate/additional/mustHaveLessThanDecimalPlaces.test.js +12 -12
- package/dist/utils/Validate/additional/mustNotContainSql.js +3 -4
- package/dist/utils/Validate/additional/mustNotContainSql.test.js +14 -14
- package/dist/utils/Validate/additional/mustSelectOnlyOne.js +2 -2
- package/dist/utils/Validate/additional/mustSelectOnlyOne.test.js +28 -26
- package/dist/utils/Validate/additional/utils.js +9 -22
- package/dist/utils/Validate/index.js +1 -1
- package/dist/utils/Validate/validateCollection.js +19 -25
- package/dist/utils/Validate/validateCollection.test.js +74 -66
- package/dist/utils/Validate/validateComponent.js +17 -15
- package/dist/utils/Validate/validateComponent.test.js +167 -146
- package/dist/utils/Validate/validateContainer.js +16 -19
- package/dist/utils/Validate/validateContainer.test.js +84 -45
- package/dist/utils/Validate/validateDate.js +15 -21
- package/dist/utils/Validate/validateDate.test.js +31 -32
- package/dist/utils/Validate/validateEmail.js +6 -8
- package/dist/utils/Validate/validateEmail.test.js +25 -25
- package/dist/utils/Validate/validateMultifile.js +5 -7
- package/dist/utils/Validate/validateMultifile.test.js +17 -18
- package/dist/utils/Validate/validatePage.js +24 -18
- package/dist/utils/Validate/validatePage.test.js +263 -182
- package/dist/utils/Validate/validateRegex.js +3 -5
- package/dist/utils/Validate/validateRegex.test.js +14 -14
- package/dist/utils/Validate/validateRequired.js +4 -6
- package/dist/utils/Validate/validateRequired.test.js +18 -18
- package/dist/utils/Validate/validateTextArea.js +4 -6
- package/dist/utils/Validate/validateTextArea.test.js +20 -20
- package/dist/utils/Validate/validateTime.js +11 -18
- package/dist/utils/Validate/validateTime.test.js +16 -16
- package/dist/utils/index.js +7 -9
- package/package.json +5 -5
- package/dist/components/FormRenderer/clear-uncompleted-routes/test-data/component-used-in-multiple-pages-data.json +0 -4
- package/dist/components/FormRenderer/clear-uncompleted-routes/test-data/component-used-in-multiple-pages-form.json +0 -61
- package/dist/components/FormRenderer/clear-uncompleted-routes/test-data/data-with-collection-data-removed.json +0 -4
- package/dist/components/FormRenderer/clear-uncompleted-routes/test-data/data-with-collections.json +0 -8
- package/dist/components/FormRenderer/clear-uncompleted-routes/test-data/data-with-components-removed.json +0 -3
- package/dist/components/FormRenderer/clear-uncompleted-routes/test-data/data-with-components.json +0 -5
- package/dist/components/FormRenderer/clear-uncompleted-routes/test-data/data-with-entire-collection-removed.json +0 -3
- package/dist/components/FormRenderer/clear-uncompleted-routes/test-data/data-with-nested-component-removed.json +0 -10
- package/dist/components/FormRenderer/clear-uncompleted-routes/test-data/data-with-nested-components.json +0 -11
- package/dist/components/FormRenderer/clear-uncompleted-routes/test-data/form-for-nested-components.json +0 -96
- package/dist/components/FormRenderer/clear-uncompleted-routes/test-data/form-with-collections-delete-entire.json +0 -47
- package/dist/components/FormRenderer/clear-uncompleted-routes/test-data/form-with-collections.json +0 -46
- package/dist/components/FormRenderer/clear-uncompleted-routes/test-data/form-with-components.json +0 -48
- package/dist/components/FormRenderer/helpers/clearOutUncompletedRoutes.js +0 -175
- package/dist/components/FormRenderer/helpers/clearOutUncompletedRoutes.test.js +0 -113
- package/dist/components/FormRenderer/helpers/deleteNodeByPath.js +0 -20
- package/dist/components/FormRenderer/helpers/deleteNodeByPath.test.js +0 -56
|
@@ -3,129 +3,130 @@
|
|
|
3
3
|
var _models = require("../../models");
|
|
4
4
|
var _validateComponent = _interopRequireDefault(require("./validateComponent"));
|
|
5
5
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
label: label,
|
|
19
|
-
required: required,
|
|
20
|
-
additionalValidation: additionalValidation
|
|
21
|
-
};
|
|
22
|
-
};
|
|
23
|
-
it('should return no error when the component is null', function () {
|
|
6
|
+
// Local imports
|
|
7
|
+
|
|
8
|
+
describe('utils.Validate.Component', () => {
|
|
9
|
+
const setup = (id, type, label, required, additionalValidation) => ({
|
|
10
|
+
id,
|
|
11
|
+
fieldId: id,
|
|
12
|
+
type,
|
|
13
|
+
label,
|
|
14
|
+
required,
|
|
15
|
+
additionalValidation
|
|
16
|
+
});
|
|
17
|
+
it('should return no error when the component is null', () => {
|
|
24
18
|
expect((0, _validateComponent.default)(null, {})).toBeUndefined();
|
|
25
19
|
});
|
|
26
|
-
describe('when there is no form data',
|
|
27
|
-
it('should return no error when the component is not required and not an email type',
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
20
|
+
describe('when there is no form data', () => {
|
|
21
|
+
it('should return no error when the component is not required and not an email type', () => {
|
|
22
|
+
const ID = 'field';
|
|
23
|
+
const LABEL = 'Field';
|
|
24
|
+
const COMPONENT = setup(ID, _models.ComponentTypes.TEXT, LABEL, false);
|
|
31
25
|
expect((0, _validateComponent.default)(COMPONENT, null)).toBeUndefined();
|
|
32
26
|
});
|
|
33
|
-
it('should return a required error when the component is required and not an email type',
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
27
|
+
it('should return a required error when the component is required and not an email type', () => {
|
|
28
|
+
const ID = 'field';
|
|
29
|
+
const LABEL = 'Field';
|
|
30
|
+
const COMPONENT = setup(ID, _models.ComponentTypes.TEXT, LABEL, true);
|
|
37
31
|
expect((0, _validateComponent.default)(COMPONENT, null)).toEqual({
|
|
38
32
|
id: ID,
|
|
39
33
|
error: "".concat(LABEL, " is required")
|
|
40
34
|
});
|
|
41
35
|
});
|
|
42
|
-
it('should return a required error when the component is required and of type email',
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
36
|
+
it('should return a required error when the component is required and of type email', () => {
|
|
37
|
+
const ID = 'field';
|
|
38
|
+
const LABEL = 'Field';
|
|
39
|
+
const COMPONENT = setup(ID, _models.ComponentTypes.EMAIL, LABEL, true);
|
|
46
40
|
expect((0, _validateComponent.default)(COMPONENT, null)).toEqual({
|
|
47
41
|
id: ID,
|
|
48
42
|
error: "".concat(LABEL, " is required")
|
|
49
43
|
});
|
|
50
44
|
});
|
|
51
|
-
it('should return a required error when the component is required and of type collection summary',
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
45
|
+
it('should return a required error when the component is required and of type collection summary', () => {
|
|
46
|
+
const ID = 'field';
|
|
47
|
+
const LABEL = 'Field';
|
|
48
|
+
const COMPONENT = {
|
|
49
|
+
...setup(ID, _models.ComponentTypes.COLLECTION_SUMMARY, LABEL, true),
|
|
55
50
|
collectionName: 'testCollection'
|
|
56
|
-
}
|
|
51
|
+
};
|
|
57
52
|
expect((0, _validateComponent.default)(COMPONENT, {})).toEqual({
|
|
58
53
|
id: ID,
|
|
59
54
|
error: "".concat(LABEL, " is required")
|
|
60
55
|
});
|
|
61
56
|
});
|
|
62
|
-
it('should return no error when the component is of type email but not required',
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
57
|
+
it('should return no error when the component is of type email but not required', () => {
|
|
58
|
+
const ID = 'field';
|
|
59
|
+
const LABEL = 'Field';
|
|
60
|
+
const COMPONENT = setup(ID, _models.ComponentTypes.EMAIL, LABEL, false);
|
|
66
61
|
expect((0, _validateComponent.default)(COMPONENT, null)).toBeUndefined();
|
|
67
62
|
});
|
|
68
63
|
});
|
|
69
|
-
describe('when the value is fully valid',
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
64
|
+
describe('when the value is fully valid', () => {
|
|
65
|
+
const ID = 'field';
|
|
66
|
+
const DATA = {
|
|
67
|
+
[ID]: 'alpha.bravo@digital.homeoffice.gov.uk'
|
|
68
|
+
};
|
|
69
|
+
it('should return no error when the component is not required and not an email type', () => {
|
|
70
|
+
const LABEL = 'Field';
|
|
71
|
+
const COMPONENT = setup(ID, _models.ComponentTypes.TEXT, LABEL, false);
|
|
75
72
|
expect((0, _validateComponent.default)(COMPONENT, DATA)).toBeUndefined();
|
|
76
73
|
});
|
|
77
|
-
it('should return no error when the component is required and not an email type',
|
|
78
|
-
|
|
79
|
-
|
|
74
|
+
it('should return no error when the component is required and not an email type', () => {
|
|
75
|
+
const LABEL = 'Field';
|
|
76
|
+
const COMPONENT = setup(ID, _models.ComponentTypes.TEXT, LABEL, true);
|
|
80
77
|
expect((0, _validateComponent.default)(COMPONENT, DATA)).toBeUndefined();
|
|
81
78
|
});
|
|
82
|
-
it('should return no error when the component is required and of type email',
|
|
83
|
-
|
|
84
|
-
|
|
79
|
+
it('should return no error when the component is required and of type email', () => {
|
|
80
|
+
const LABEL = 'Field';
|
|
81
|
+
const COMPONENT = setup(ID, _models.ComponentTypes.EMAIL, LABEL, true);
|
|
85
82
|
expect((0, _validateComponent.default)(COMPONENT, DATA)).toBeUndefined();
|
|
86
83
|
});
|
|
87
|
-
it('should return no error when the component is of type email but not required',
|
|
88
|
-
|
|
89
|
-
|
|
84
|
+
it('should return no error when the component is of type email but not required', () => {
|
|
85
|
+
const LABEL = 'Field';
|
|
86
|
+
const COMPONENT = setup(ID, _models.ComponentTypes.EMAIL, LABEL, false);
|
|
90
87
|
expect((0, _validateComponent.default)(COMPONENT, DATA)).toBeUndefined();
|
|
91
88
|
});
|
|
92
89
|
});
|
|
93
|
-
describe('when the value is an invalid email',
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
90
|
+
describe('when the value is an invalid email', () => {
|
|
91
|
+
const ID = 'field';
|
|
92
|
+
const DATA = {
|
|
93
|
+
[ID]: 'alpha.bravo@hotmail.com'
|
|
94
|
+
};
|
|
95
|
+
it('should return no error when the component is not required and not an email type', () => {
|
|
96
|
+
const LABEL = 'Field';
|
|
97
|
+
const COMPONENT = setup(ID, _models.ComponentTypes.TEXT, LABEL, false);
|
|
99
98
|
expect((0, _validateComponent.default)(COMPONENT, DATA)).toBeUndefined();
|
|
100
99
|
});
|
|
101
|
-
it('should return no error when the component is required and not an email type',
|
|
102
|
-
|
|
103
|
-
|
|
100
|
+
it('should return no error when the component is required and not an email type', () => {
|
|
101
|
+
const LABEL = 'Field';
|
|
102
|
+
const COMPONENT = setup(ID, _models.ComponentTypes.TEXT, LABEL, true);
|
|
104
103
|
expect((0, _validateComponent.default)(COMPONENT, DATA)).toBeUndefined();
|
|
105
104
|
});
|
|
106
|
-
it('should return no error when the component is required and of type email',
|
|
107
|
-
|
|
108
|
-
|
|
105
|
+
it('should return no error when the component is required and of type email', () => {
|
|
106
|
+
const LABEL = 'Field';
|
|
107
|
+
const COMPONENT = setup(ID, _models.ComponentTypes.EMAIL, LABEL, true);
|
|
109
108
|
expect((0, _validateComponent.default)(COMPONENT, DATA)).toEqual({
|
|
110
109
|
id: ID,
|
|
111
110
|
error: "Enter ".concat(LABEL.toLowerCase(), " in the correct format, like jane.doe@homeoffice.gov.uk")
|
|
112
111
|
});
|
|
113
112
|
});
|
|
114
|
-
it('should return no error when the component is of type email but not required',
|
|
115
|
-
|
|
116
|
-
|
|
113
|
+
it('should return no error when the component is of type email but not required', () => {
|
|
114
|
+
const LABEL = 'Field';
|
|
115
|
+
const COMPONENT = setup(ID, _models.ComponentTypes.EMAIL, LABEL, false);
|
|
117
116
|
expect((0, _validateComponent.default)(COMPONENT, DATA)).toEqual({
|
|
118
117
|
id: ID,
|
|
119
118
|
error: "Enter ".concat(LABEL.toLowerCase(), " in the correct format, like jane.doe@homeoffice.gov.uk")
|
|
120
119
|
});
|
|
121
120
|
});
|
|
122
121
|
});
|
|
123
|
-
describe('when the component is a Date Input',
|
|
124
|
-
|
|
125
|
-
it('should always reject invalid dates',
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
122
|
+
describe('when the component is a Date Input', () => {
|
|
123
|
+
const ID = 'field';
|
|
124
|
+
it('should always reject invalid dates', () => {
|
|
125
|
+
const LABEL = 'Field';
|
|
126
|
+
const COMPONENT = setup(ID, _models.ComponentTypes.DATE, LABEL, false);
|
|
127
|
+
const DATA = {
|
|
128
|
+
[ID]: '25-45-2033'
|
|
129
|
+
};
|
|
129
130
|
expect((0, _validateComponent.default)(COMPONENT, DATA)).toEqual({
|
|
130
131
|
error: 'Month must be between 1 and 12',
|
|
131
132
|
id: ID,
|
|
@@ -134,16 +135,18 @@ describe('utils.Validate.Component', function () {
|
|
|
134
135
|
}
|
|
135
136
|
});
|
|
136
137
|
});
|
|
137
|
-
it('should apply optional validators when specified',
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
138
|
+
it('should apply optional validators when specified', () => {
|
|
139
|
+
const LABEL = 'Field';
|
|
140
|
+
const DATA = {
|
|
141
|
+
[ID]: '25-3-3033'
|
|
142
|
+
};
|
|
143
|
+
const ADDITIONAL_VALIDATION = [{
|
|
141
144
|
function: 'mustBeBefore',
|
|
142
145
|
value: 3,
|
|
143
146
|
unit: 'day',
|
|
144
147
|
message: 'Date must be less than 3 days in the future'
|
|
145
148
|
}];
|
|
146
|
-
|
|
149
|
+
const COMPONENT = setup(ID, _models.ComponentTypes.DATE, LABEL, false, ADDITIONAL_VALIDATION);
|
|
147
150
|
expect((0, _validateComponent.default)(COMPONENT, DATA)).toEqual({
|
|
148
151
|
error: 'Date must be less than 3 days in the future',
|
|
149
152
|
id: ID,
|
|
@@ -155,12 +158,14 @@ describe('utils.Validate.Component', function () {
|
|
|
155
158
|
});
|
|
156
159
|
});
|
|
157
160
|
});
|
|
158
|
-
describe('when the component is a Time Input',
|
|
159
|
-
|
|
160
|
-
it('should always reject invalid time',
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
161
|
+
describe('when the component is a Time Input', () => {
|
|
162
|
+
const ID = 'field';
|
|
163
|
+
it('should always reject invalid time', () => {
|
|
164
|
+
const LABEL = 'Field';
|
|
165
|
+
const COMPONENT = setup(ID, _models.ComponentTypes.TIME, LABEL, false);
|
|
166
|
+
const DATA = {
|
|
167
|
+
[ID]: '25:45'
|
|
168
|
+
};
|
|
164
169
|
expect((0, _validateComponent.default)(COMPONENT, DATA)).toEqual({
|
|
165
170
|
error: 'Hour must be between 0 and 23',
|
|
166
171
|
id: ID,
|
|
@@ -170,38 +175,50 @@ describe('utils.Validate.Component', function () {
|
|
|
170
175
|
});
|
|
171
176
|
});
|
|
172
177
|
});
|
|
173
|
-
describe('when the component is a container',
|
|
174
|
-
it('should return an empty array when the container has only valid components',
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
178
|
+
describe('when the component is a container', () => {
|
|
179
|
+
it('should return an empty array when the container has only valid components', () => {
|
|
180
|
+
const EMAIL_ID = 'email';
|
|
181
|
+
const EMAIL_LABEL = 'Email';
|
|
182
|
+
const EMAIL = setup(EMAIL_ID, _models.ComponentTypes.EMAIL, EMAIL_LABEL, false);
|
|
183
|
+
const ID = 'container';
|
|
184
|
+
const LABEL = 'field';
|
|
185
|
+
const CONTAINER = setup(ID, _models.ComponentTypes.CONTAINER, LABEL, false);
|
|
181
186
|
CONTAINER.components = [EMAIL];
|
|
182
|
-
|
|
187
|
+
const DATA = {
|
|
188
|
+
[ID]: {
|
|
189
|
+
[EMAIL_ID]: 'alpha.bravo@digital.homeoffice.gov.uk'
|
|
190
|
+
}
|
|
191
|
+
};
|
|
183
192
|
expect((0, _validateComponent.default)(CONTAINER, DATA)).toEqual([]);
|
|
184
193
|
});
|
|
185
194
|
});
|
|
186
|
-
describe('when the component is a collection',
|
|
187
|
-
it('should return an empty array when the collection has only valid items',
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
195
|
+
describe('when the component is a collection', () => {
|
|
196
|
+
it('should return an empty array when the collection has only valid items', () => {
|
|
197
|
+
const EMAIL_ID = 'email';
|
|
198
|
+
const EMAIL_LABEL = 'Email';
|
|
199
|
+
const EMAIL = setup(EMAIL_ID, _models.ComponentTypes.EMAIL, EMAIL_LABEL, false);
|
|
200
|
+
const ID = 'collection';
|
|
201
|
+
const LABEL = 'field';
|
|
202
|
+
const COLLECTION = setup(ID, _models.ComponentTypes.COLLECTION, LABEL, false);
|
|
194
203
|
COLLECTION.item = [EMAIL];
|
|
195
|
-
|
|
204
|
+
const DATA = {
|
|
205
|
+
[ID]: [{
|
|
206
|
+
[EMAIL_ID]: 'alpha.bravo@homeoffice.gov.uk'
|
|
207
|
+
}, {
|
|
208
|
+
[EMAIL_ID]: 'charlie.delta@homeoffice.gov.uk'
|
|
209
|
+
}]
|
|
210
|
+
};
|
|
196
211
|
expect((0, _validateComponent.default)(COLLECTION, DATA)).toEqual([]);
|
|
197
212
|
});
|
|
198
213
|
});
|
|
199
|
-
describe('when the component has a nested component',
|
|
200
|
-
it('should return no error when the radio component contains nested components without errors',
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
214
|
+
describe('when the component has a nested component', () => {
|
|
215
|
+
it('should return no error when the radio component contains nested components without errors', () => {
|
|
216
|
+
const NESTED_ID = 'nestedId';
|
|
217
|
+
const NESTED_VALUE = 'nestedValue';
|
|
218
|
+
const FORMDATA = {
|
|
219
|
+
[NESTED_ID]: NESTED_VALUE
|
|
220
|
+
};
|
|
221
|
+
const COMPONENT = {
|
|
205
222
|
type: 'radios',
|
|
206
223
|
id: 'a',
|
|
207
224
|
data: {
|
|
@@ -217,10 +234,10 @@ describe('utils.Validate.Component', function () {
|
|
|
217
234
|
};
|
|
218
235
|
expect((0, _validateComponent.default)(COMPONENT, undefined, FORMDATA)).toBeUndefined();
|
|
219
236
|
});
|
|
220
|
-
it('should return an error when the radio component contains nested components with errors',
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
237
|
+
it('should return an error when the radio component contains nested components with errors', () => {
|
|
238
|
+
const NESTED_ID = 'nestedId';
|
|
239
|
+
const FORMDATA = {};
|
|
240
|
+
const COMPONENT = {
|
|
224
241
|
type: 'radios',
|
|
225
242
|
id: 'a',
|
|
226
243
|
data: {
|
|
@@ -239,9 +256,9 @@ describe('utils.Validate.Component', function () {
|
|
|
239
256
|
error: "Field is required"
|
|
240
257
|
}]);
|
|
241
258
|
});
|
|
242
|
-
it('should return no error when a non selected radio component contains nested components with errors',
|
|
243
|
-
|
|
244
|
-
|
|
259
|
+
it('should return no error when a non selected radio component contains nested components with errors', () => {
|
|
260
|
+
const NESTED_ID = 'nestedId';
|
|
261
|
+
const COMPONENT = {
|
|
245
262
|
type: 'radios',
|
|
246
263
|
id: 'a',
|
|
247
264
|
data: {
|
|
@@ -258,11 +275,13 @@ describe('utils.Validate.Component', function () {
|
|
|
258
275
|
};
|
|
259
276
|
expect((0, _validateComponent.default)(COMPONENT, undefined, {})).toBeUndefined();
|
|
260
277
|
});
|
|
261
|
-
it('should return no error when the checkbox component contains nested components without errors',
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
278
|
+
it('should return no error when the checkbox component contains nested components without errors', () => {
|
|
279
|
+
const NESTED_ID = 'nestedId';
|
|
280
|
+
const NESTED_VALUE = 'nestedValue';
|
|
281
|
+
const FORMDATA = {
|
|
282
|
+
[NESTED_ID]: NESTED_VALUE
|
|
283
|
+
};
|
|
284
|
+
const COMPONENT = {
|
|
266
285
|
type: 'checkboxes',
|
|
267
286
|
id: 'a',
|
|
268
287
|
data: {
|
|
@@ -278,13 +297,13 @@ describe('utils.Validate.Component', function () {
|
|
|
278
297
|
};
|
|
279
298
|
expect((0, _validateComponent.default)(COMPONENT, undefined, FORMDATA)).toBeUndefined();
|
|
280
299
|
});
|
|
281
|
-
it('should return an error when the checkbox component contains nested components with errors',
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
300
|
+
it('should return an error when the checkbox component contains nested components with errors', () => {
|
|
301
|
+
const NESTED_ID = 'nestedId';
|
|
302
|
+
const OPTION_VALUE = 'optionValue';
|
|
303
|
+
const FORMDATA = {
|
|
285
304
|
'a': [OPTION_VALUE]
|
|
286
305
|
};
|
|
287
|
-
|
|
306
|
+
const COMPONENT = {
|
|
288
307
|
type: 'checkboxes',
|
|
289
308
|
id: 'a',
|
|
290
309
|
data: {
|
|
@@ -304,14 +323,15 @@ describe('utils.Validate.Component', function () {
|
|
|
304
323
|
error: "Field is required"
|
|
305
324
|
}]);
|
|
306
325
|
});
|
|
307
|
-
it('should return no error when a non selected checkbox component contains nested components with errors',
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
'a': ['optionValueSelected']
|
|
313
|
-
|
|
314
|
-
|
|
326
|
+
it('should return no error when a non selected checkbox component contains nested components with errors', () => {
|
|
327
|
+
const NESTED_ID_NOT_SELECTED = 'nestedIdNotSelected';
|
|
328
|
+
const NESTED_ID_SELECTED = 'nestedIdSelected';
|
|
329
|
+
const NESTED_VALUE_SELECTED = 'nestedValueSelected';
|
|
330
|
+
const FORMDATA = {
|
|
331
|
+
'a': ['optionValueSelected'],
|
|
332
|
+
[NESTED_ID_SELECTED]: NESTED_VALUE_SELECTED
|
|
333
|
+
};
|
|
334
|
+
const COMPONENT = {
|
|
315
335
|
type: 'checkboxes',
|
|
316
336
|
id: 'a',
|
|
317
337
|
data: {
|
|
@@ -338,16 +358,17 @@ describe('utils.Validate.Component', function () {
|
|
|
338
358
|
};
|
|
339
359
|
expect((0, _validateComponent.default)(COMPONENT, undefined, FORMDATA)).toBeUndefined();
|
|
340
360
|
});
|
|
341
|
-
it('should return no error when all selected checkbox components contains nested components without errors',
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
361
|
+
it('should return no error when all selected checkbox components contains nested components without errors', () => {
|
|
362
|
+
const NESTED_ID_SELECTED_1 = 'nestedIdSelected1';
|
|
363
|
+
const NESTED_ID_SELECTED_2 = 'nestedIdSelected2';
|
|
364
|
+
const NESTED_VALUE_SELECTED_1 = 'nestedValueSelected1';
|
|
365
|
+
const NESTED_VALUE_SELECTED_2 = 'nestedValueSelected2';
|
|
366
|
+
const FORMDATA = {
|
|
367
|
+
'a': ['optionValueSelected1', 'optionValueSelected2'],
|
|
368
|
+
[NESTED_ID_SELECTED_1]: NESTED_VALUE_SELECTED_1,
|
|
369
|
+
[NESTED_ID_SELECTED_2]: NESTED_VALUE_SELECTED_2
|
|
370
|
+
};
|
|
371
|
+
const COMPONENT = {
|
|
351
372
|
type: 'checkboxes',
|
|
352
373
|
id: 'a',
|
|
353
374
|
data: {
|
|
@@ -4,15 +4,12 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.default = void 0;
|
|
7
|
+
var _elevateNestedComponents = _interopRequireDefault(require("../Component/elevateNestedComponents"));
|
|
7
8
|
var _validateComponent = _interopRequireDefault(require("./validateComponent"));
|
|
8
9
|
var _additional = _interopRequireDefault(require("./additional"));
|
|
9
10
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
13
|
-
function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
14
|
-
function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return _typeof(key) === "symbol" ? key : String(key); }
|
|
15
|
-
function _toPrimitive(input, hint) { if (_typeof(input) !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (_typeof(res) !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); } // Local imports
|
|
11
|
+
// Local imports
|
|
12
|
+
|
|
16
13
|
/**
|
|
17
14
|
* Validates all components within a container.
|
|
18
15
|
* @param {object} container The container to validate.
|
|
@@ -20,33 +17,33 @@ function _toPrimitive(input, hint) { if (_typeof(input) !== "object" || input ==
|
|
|
20
17
|
* @param {object} formData The data at the top level of the form.
|
|
21
18
|
* @returns Errors for all components within the container.
|
|
22
19
|
*/
|
|
23
|
-
|
|
20
|
+
const validateContainer = (container, outerData, formData) => {
|
|
24
21
|
if (!container) {
|
|
25
22
|
return [];
|
|
26
23
|
}
|
|
27
|
-
|
|
28
|
-
|
|
24
|
+
const fd = formData || outerData;
|
|
25
|
+
const error = (0, _additional.default)(container, fd);
|
|
29
26
|
if (error) {
|
|
30
27
|
return {
|
|
31
28
|
id: container.id,
|
|
32
|
-
error
|
|
29
|
+
error
|
|
33
30
|
};
|
|
34
31
|
}
|
|
35
|
-
|
|
32
|
+
const errors = [];
|
|
36
33
|
if (Array.isArray(container.components)) {
|
|
37
|
-
|
|
38
|
-
container.components
|
|
34
|
+
const containerData = outerData && container.fieldId ? outerData[container.fieldId] : outerData;
|
|
35
|
+
const fullContainerComponents = (0, _elevateNestedComponents.default)(container.components, containerData);
|
|
36
|
+
fullContainerComponents.forEach(component => {
|
|
39
37
|
// It is possible that the container being passed in is a
|
|
40
38
|
// dummy container just for validation. In that scenario we want
|
|
41
39
|
// to ignore the full_path and just use the component's fieldId.
|
|
42
|
-
|
|
43
|
-
errors.push((0, _validateComponent.default)(
|
|
40
|
+
const fullPath = container.full_path || container.fieldId ? "".concat(container.full_path || container.fieldId, ".").concat(component.fieldId) : component.fieldId;
|
|
41
|
+
errors.push((0, _validateComponent.default)({
|
|
42
|
+
...component,
|
|
44
43
|
full_path: fullPath
|
|
45
|
-
}
|
|
44
|
+
}, containerData, fd));
|
|
46
45
|
});
|
|
47
46
|
}
|
|
48
|
-
return errors.flat(1).filter(
|
|
49
|
-
return !!e;
|
|
50
|
-
});
|
|
47
|
+
return errors.flat(1).filter(e => !!e);
|
|
51
48
|
};
|
|
52
49
|
var _default = exports.default = validateContainer;
|