@ukhomeoffice/cop-react-form-renderer 4.18.0 → 5.0.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 +1 -14
- package/dist/components/CheckYourAnswers/CheckYourAnswers.js +19 -57
- package/dist/components/CheckYourAnswers/index.js +0 -3
- package/dist/components/CollectionPage/CollectionPage.js +8 -38
- package/dist/components/CollectionPage/index.js +0 -3
- package/dist/components/FormComponent/Collection.js +13 -54
- package/dist/components/FormComponent/Container.js +6 -30
- package/dist/components/FormComponent/FormComponent.js +14 -57
- package/dist/components/FormComponent/helpers/addLabel.js +4 -7
- package/dist/components/FormComponent/helpers/getComponentDisabled.js +0 -4
- package/dist/components/FormComponent/helpers/getComponentDisabled.test.js +0 -2
- package/dist/components/FormComponent/helpers/getComponentError.js +0 -6
- package/dist/components/FormComponent/helpers/getComponentError.test.js +0 -2
- package/dist/components/FormComponent/helpers/index.js +0 -4
- package/dist/components/FormComponent/index.js +0 -3
- package/dist/components/FormPage/FormPage.js +14 -45
- package/dist/components/FormPage/index.js +0 -3
- package/dist/components/FormRenderer/FormRenderer.js +106 -189
- package/dist/components/FormRenderer/handlers/cyaAction.js +0 -5
- package/dist/components/FormRenderer/handlers/getPageId.js +0 -2
- package/dist/components/FormRenderer/handlers/getPageId.test.js +1 -2
- package/dist/components/FormRenderer/handlers/handlers.test.js +1 -18
- package/dist/components/FormRenderer/handlers/index.js +0 -5
- package/dist/components/FormRenderer/handlers/navigate.js +0 -5
- package/dist/components/FormRenderer/handlers/submissionError.js +0 -2
- package/dist/components/FormRenderer/helpers/canActionProceed.js +0 -3
- package/dist/components/FormRenderer/helpers/canActionProceed.test.js +1 -3
- package/dist/components/FormRenderer/helpers/canCYASubmit.js +0 -2
- package/dist/components/FormRenderer/helpers/canCYASubmit.test.js +1 -5
- package/dist/components/FormRenderer/helpers/cleanHiddenNestedData.js +0 -5
- package/dist/components/FormRenderer/helpers/cleanHiddenNestedData.test.js +1 -2
- package/dist/components/FormRenderer/helpers/getCYA.js +0 -6
- package/dist/components/FormRenderer/helpers/getCYA.test.js +1 -3
- package/dist/components/FormRenderer/helpers/getFormState.js +0 -5
- package/dist/components/FormRenderer/helpers/getFormState.test.js +1 -3
- package/dist/components/FormRenderer/helpers/getNextPageId.js +0 -25
- package/dist/components/FormRenderer/helpers/getNextPageId.test.js +1 -4
- package/dist/components/FormRenderer/helpers/getPage.js +0 -5
- package/dist/components/FormRenderer/helpers/getPage.test.js +1 -3
- package/dist/components/FormRenderer/helpers/getRelevantPages.js +0 -6
- package/dist/components/FormRenderer/helpers/getRelevantPages.test.js +1 -3
- package/dist/components/FormRenderer/helpers/getSubmissionStatus.js +0 -10
- package/dist/components/FormRenderer/helpers/getSubmissionStatus.test.js +0 -6
- package/dist/components/FormRenderer/helpers/getUpdatedSectionStates.js +6 -20
- package/dist/components/FormRenderer/helpers/getUpdatedSectionStates.test.js +3 -8
- package/dist/components/FormRenderer/helpers/index.js +1 -11
- package/dist/components/FormRenderer/index.js +0 -3
- package/dist/components/PageActions/ActionButton.js +2 -17
- package/dist/components/PageActions/PageActions.js +3 -10
- package/dist/components/PageActions/index.js +0 -3
- package/dist/components/SummaryList/GroupAction.js +3 -24
- package/dist/components/SummaryList/RowAction.js +3 -23
- package/dist/components/SummaryList/SummaryList.js +6 -28
- package/dist/components/SummaryList/SummaryListRow.js +4 -8
- package/dist/components/SummaryList/SummaryListTitleRow.js +2 -7
- package/dist/components/SummaryList/helpers/getGroupActionAttributes.js +0 -3
- package/dist/components/SummaryList/helpers/getGroupActionAttributes.test.js +0 -6
- package/dist/components/SummaryList/helpers/getRowActionAttributes.js +0 -3
- package/dist/components/SummaryList/helpers/getRowActionAttributes.test.js +0 -6
- package/dist/components/SummaryList/helpers/index.js +0 -2
- package/dist/components/SummaryList/index.js +0 -3
- package/dist/components/TaskList/Task.js +7 -29
- package/dist/components/TaskList/TaskList.js +12 -33
- package/dist/components/TaskList/TaskState.js +2 -10
- package/dist/components/TaskList/index.js +0 -3
- package/dist/components/index.js +0 -6
- package/dist/context/HooksContext/HooksContext.js +14 -34
- package/dist/context/HooksContext/index.js +0 -5
- package/dist/context/ValidationContext/ValidationContext.js +8 -34
- package/dist/context/ValidationContext/index.js +0 -5
- package/dist/context/index.js +0 -3
- package/dist/hooks/index.js +0 -9
- package/dist/hooks/useAxios.js +8 -25
- package/dist/hooks/useGetRequest.js +13 -47
- package/dist/hooks/useHooks.js +2 -4
- package/dist/hooks/useRefData.js +8 -37
- package/dist/hooks/useValidation.js +2 -4
- package/dist/index.js +0 -6
- package/dist/models/PageAction.js +0 -3
- package/dist/models/TaskStates.js +0 -3
- package/dist/models/index.js +0 -9
- package/dist/utils/CheckYourAnswers/getCYAAction.js +1 -9
- package/dist/utils/CheckYourAnswers/getCYACollectionChangeAction.js +0 -10
- package/dist/utils/CheckYourAnswers/getCYACollectionDeleteAction.js +0 -8
- package/dist/utils/CheckYourAnswers/getCYARow.js +1 -10
- package/dist/utils/CheckYourAnswers/getCYARowForGroup.js +2 -20
- package/dist/utils/CheckYourAnswers/getCYARowsForCollection.js +0 -18
- package/dist/utils/CheckYourAnswers/getCYARowsForCollectionPage.js +0 -20
- package/dist/utils/CheckYourAnswers/getCYARowsForContainer.js +0 -13
- package/dist/utils/CheckYourAnswers/getCYARowsForPage.js +2 -22
- package/dist/utils/CheckYourAnswers/index.js +1 -3
- package/dist/utils/CheckYourAnswers/showComponentCYA.js +2 -11
- package/dist/utils/CollectionPage/duplicateCollectionPageActiveEntry.js +0 -11
- package/dist/utils/CollectionPage/getCollectionPageActiveIndex.js +0 -6
- package/dist/utils/CollectionPage/index.js +1 -5
- package/dist/utils/CollectionPage/mergeCollectionPages.js +1 -12
- package/dist/utils/Component/cleanAttributes.js +1 -8
- package/dist/utils/Component/elevateNestedComponents.js +0 -3
- package/dist/utils/Component/getComponent.js +4 -68
- package/dist/utils/Component/getComponentTests/getComponent.autocomplete.test.js +6 -10
- package/dist/utils/Component/getComponentTests/getComponent.calculation.test.js +10 -28
- package/dist/utils/Component/getComponentTests/getComponent.checkboxes.test.js +6 -33
- package/dist/utils/Component/getComponentTests/getComponent.date.test.js +10 -27
- package/dist/utils/Component/getComponentTests/getComponent.details.test.js +4 -10
- package/dist/utils/Component/getComponentTests/getComponent.email.test.js +4 -21
- package/dist/utils/Component/getComponentTests/getComponent.file.test.js +4 -22
- package/dist/utils/Component/getComponentTests/getComponent.heading.test.js +3 -7
- package/dist/utils/Component/getComponentTests/getComponent.html.test.js +4 -10
- package/dist/utils/Component/getComponentTests/getComponent.insetText.test.js +3 -7
- package/dist/utils/Component/getComponentTests/getComponent.nested.test.js +6 -15
- package/dist/utils/Component/getComponentTests/getComponent.phoneNumber.test.js +4 -21
- package/dist/utils/Component/getComponentTests/getComponent.radios.test.js +6 -33
- package/dist/utils/Component/getComponentTests/getComponent.select.test.js +4 -21
- package/dist/utils/Component/getComponentTests/getComponent.text.test.js +4 -21
- package/dist/utils/Component/getComponentTests/getComponent.textarea.test.js +4 -21
- package/dist/utils/Component/getComponentTests/getComponent.time.test.js +10 -29
- package/dist/utils/Component/getComponentTests/getComponent.unknown.test.js +1 -2
- package/dist/utils/Component/getComponentTests/getComponent.warningText.test.js +3 -7
- package/dist/utils/Component/getDefaultValue.js +0 -7
- package/dist/utils/Component/index.js +0 -9
- package/dist/utils/Component/isEditable.js +1 -4
- package/dist/utils/Component/showComponent.js +1 -8
- package/dist/utils/Component/wrapInFormGroup.js +0 -7
- package/dist/utils/Condition/index.js +0 -5
- package/dist/utils/Condition/meetsAllConditions.js +0 -9
- package/dist/utils/Condition/meetsCondition.js +7 -19
- package/dist/utils/Condition/meetsOneCondition.js +1 -9
- package/dist/utils/Condition/setupConditions.js +0 -12
- package/dist/utils/Container/getEditableComponents.js +0 -7
- package/dist/utils/Container/index.js +0 -5
- package/dist/utils/Container/setupNesting.js +0 -11
- package/dist/utils/Container/showContainer.js +9 -18
- package/dist/utils/Data/applyFormula.js +2 -28
- package/dist/utils/Data/getAutocompleteSource.js +1 -4
- package/dist/utils/Data/getDataPath.js +3 -17
- package/dist/utils/Data/getOptions.js +0 -9
- package/dist/utils/Data/getSourceData.js +4 -19
- package/dist/utils/Data/index.js +1 -11
- package/dist/utils/Data/refDataToOptions.js +1 -12
- package/dist/utils/Data/setDataItem.js +0 -5
- package/dist/utils/Data/setupFormData.js +2 -20
- package/dist/utils/Data/setupRefDataUrlForComponent.js +0 -14
- package/dist/utils/FormPage/getFormPage.js +0 -15
- package/dist/utils/FormPage/getFormPages.js +0 -8
- package/dist/utils/FormPage/getPageActions.js +3 -18
- package/dist/utils/FormPage/getParagraphFromText.js +0 -3
- package/dist/utils/FormPage/index.js +0 -6
- package/dist/utils/FormPage/showFormPage.js +9 -18
- package/dist/utils/FormPage/showFormPageCYA.js +0 -5
- package/dist/utils/FormPage/useComponent.js +3 -18
- package/dist/utils/Format/formatData.js +0 -5
- package/dist/utils/Format/formatDataForComponent.js +1 -6
- package/dist/utils/Format/formatDataForForm.js +0 -8
- package/dist/utils/Format/formatDataForPage.js +1 -5
- package/dist/utils/Format/index.js +1 -6
- package/dist/utils/Hub/getFormHub.js +0 -8
- package/dist/utils/Hub/index.js +1 -3
- package/dist/utils/Meta/documents/getDocuments.js +1 -4
- package/dist/utils/Meta/documents/getDocuments.test.js +0 -9
- package/dist/utils/Meta/documents/index.js +1 -5
- package/dist/utils/Meta/documents/setDocumentForField.js +0 -11
- package/dist/utils/Meta/documents/setDocumentForField.test.js +0 -11
- package/dist/utils/Meta/index.js +2 -6
- package/dist/utils/Operate/checkValueIsTruthy.js +1 -7
- package/dist/utils/Operate/getIndexOfMatchingValueIn.js +7 -21
- package/dist/utils/Operate/index.js +0 -3
- package/dist/utils/Operate/persistValueInFormData.js +1 -8
- package/dist/utils/Operate/runPageOperations.js +3 -18
- package/dist/utils/Operate/setValueInFormData.js +2 -7
- package/dist/utils/Operate/shouldRun.js +1 -14
- package/dist/utils/Validate/additional/index.js +1 -18
- package/dist/utils/Validate/additional/index.test.js +0 -6
- package/dist/utils/Validate/additional/mustBeAfter.js +3 -8
- package/dist/utils/Validate/additional/mustBeAfter.test.js +0 -4
- package/dist/utils/Validate/additional/mustBeBefore.js +3 -8
- package/dist/utils/Validate/additional/mustBeBefore.test.js +0 -4
- package/dist/utils/Validate/additional/mustBeEarlierDateTime.js +5 -16
- package/dist/utils/Validate/additional/mustBeEarlierDateTime.test.js +0 -7
- package/dist/utils/Validate/additional/mustBeInTheFuture.js +3 -12
- package/dist/utils/Validate/additional/mustBeInTheFuture.test.js +0 -3
- package/dist/utils/Validate/additional/mustBeInThePast.js +5 -13
- package/dist/utils/Validate/additional/mustBeInThePast.test.js +0 -3
- package/dist/utils/Validate/additional/mustBeLessThan.js +0 -3
- package/dist/utils/Validate/additional/mustBeLessThan.test.js +0 -2
- package/dist/utils/Validate/additional/mustBeLongerThan.js +0 -3
- package/dist/utils/Validate/additional/mustBeLongerThan.test.js +0 -2
- package/dist/utils/Validate/additional/mustBeNumbersOnly.js +0 -4
- package/dist/utils/Validate/additional/mustBeNumbersOnly.test.js +0 -2
- package/dist/utils/Validate/additional/mustBeShorterThan.js +0 -3
- package/dist/utils/Validate/additional/mustBeShorterThan.test.js +0 -2
- package/dist/utils/Validate/additional/mustEnterAtLeastOne.js +0 -5
- package/dist/utils/Validate/additional/mustEnterAtLeastOne.test.js +0 -4
- package/dist/utils/Validate/additional/utils.js +8 -24
- package/dist/utils/Validate/index.js +1 -9
- package/dist/utils/Validate/validateCollection.js +0 -9
- package/dist/utils/Validate/validateComponent.js +2 -35
- package/dist/utils/Validate/validateContainer.js +0 -13
- package/dist/utils/Validate/validateDate.js +4 -36
- package/dist/utils/Validate/validateEmail.js +1 -7
- package/dist/utils/Validate/validatePage.js +0 -15
- package/dist/utils/Validate/validateRegex.js +0 -10
- package/dist/utils/Validate/validateRequired.js +0 -8
- package/dist/utils/Validate/validateTime.js +3 -20
- package/dist/utils/index.js +0 -19
- package/package.json +50 -34
- package/dist/components/CheckYourAnswers/Answer.test.js +0 -95
- package/dist/components/CheckYourAnswers/CheckYourAnswers.stories.mdx +0 -410
- package/dist/components/CheckYourAnswers/CheckYourAnswers.test.js +0 -680
- package/dist/components/CollectionPage/CollectionPage.test.js +0 -428
- package/dist/components/FormComponent/Collection.test.js +0 -381
- package/dist/components/FormComponent/Container.test.js +0 -423
- package/dist/components/FormComponent/FormComponent.stories.mdx +0 -184
- package/dist/components/FormComponent/FormComponent.test.js +0 -264
- package/dist/components/FormPage/FormPage.stories.mdx +0 -131
- package/dist/components/FormPage/FormPage.test.js +0 -368
- package/dist/components/FormRenderer/FormRenderer.stories.mdx +0 -183
- package/dist/components/FormRenderer/FormRenderer.test.js +0 -1006
- package/dist/components/PageActions/ActionButton.test.js +0 -116
- package/dist/components/PageActions/PageActions.stories.mdx +0 -74
- package/dist/components/PageActions/PageActions.test.js +0 -157
- package/dist/components/SummaryList/GroupAction.test.js +0 -94
- package/dist/components/SummaryList/RowAction.test.js +0 -94
- package/dist/components/SummaryList/SummaryList.stories.mdx +0 -90
- package/dist/components/SummaryList/SummaryList.test.js +0 -361
- package/dist/components/TaskList/Task.test.js +0 -194
- package/dist/components/TaskList/TaskList.stories.mdx +0 -164
- package/dist/components/TaskList/TaskList.test.js +0 -334
- package/dist/components/TaskList/TaskState.test.js +0 -104
- package/dist/context/HooksContext/HooksContext.test.js +0 -60
- package/dist/context/ValidationContext/ValidationContext.test.js +0 -98
- package/dist/json/areYouACivilServant.json +0 -7
- package/dist/json/firstForm.json +0 -94
- package/dist/json/grade.json +0 -108
- package/dist/json/group.data.json +0 -21
- package/dist/json/group.json +0 -402
- package/dist/json/groupOfRow.json +0 -137
- package/dist/json/groupOfRowData.json +0 -15
- package/dist/json/port.json +0 -346
- package/dist/json/saveAndContinue.json +0 -98
- package/dist/json/sublocation.json +0 -859
- package/dist/json/taskList.json +0 -265
- package/dist/json/team.json +0 -17351
- package/dist/json/terminal.json +0 -81
- package/dist/json/userProfile.data.json +0 -21
- package/dist/json/userProfile.json +0 -276
- package/dist/setupTests.js +0 -59
- package/dist/utils/CheckYourAnswers/getCYAAction.test.js +0 -139
- package/dist/utils/CheckYourAnswers/getCYACollectionChangeAction.test.js +0 -76
- package/dist/utils/CheckYourAnswers/getCYACollectionDeleteAction.test.js +0 -59
- package/dist/utils/CheckYourAnswers/getCYARow.test.js +0 -256
- package/dist/utils/CheckYourAnswers/getCYARowForGroup.test.js +0 -77
- package/dist/utils/CheckYourAnswers/getCYARowsForCollection.test.js +0 -199
- package/dist/utils/CheckYourAnswers/getCYARowsForCollectionPage.test.js +0 -170
- package/dist/utils/CheckYourAnswers/getCYARowsForContainer.test.js +0 -323
- package/dist/utils/CheckYourAnswers/getCYARowsForPage.test.js +0 -281
- package/dist/utils/CheckYourAnswers/showComponentCYA.test.js +0 -64
- package/dist/utils/CollectionPage/duplicateCollectionPageActiveEntry.test.js +0 -41
- package/dist/utils/CollectionPage/getCollectionPageActiveIndex.test.js +0 -54
- package/dist/utils/CollectionPage/mergeCollectionPages.test.js +0 -131
- package/dist/utils/Component/cleanAttributes.test.js +0 -69
- package/dist/utils/Component/elevateNestedComponents.test.js +0 -92
- package/dist/utils/Component/getDefaultValue.test.js +0 -53
- package/dist/utils/Component/isEditable.test.js +0 -42
- package/dist/utils/Component/showComponent.test.js +0 -157
- package/dist/utils/Condition/meetsAllConditions.test.js +0 -62
- package/dist/utils/Condition/meetsCondition.test.js +0 -391
- package/dist/utils/Condition/meetsOneCondition.test.js +0 -101
- package/dist/utils/Condition/setupConditions.test.js +0 -35
- package/dist/utils/Container/getEditableComponents.test.js +0 -146
- package/dist/utils/Container/setupNesting.test.js +0 -92
- package/dist/utils/Container/showContainer.test.js +0 -179
- package/dist/utils/Data/applyFormula.test.js +0 -264
- package/dist/utils/Data/getAutocompleteSource.test.js +0 -146
- package/dist/utils/Data/getDataPath.test.js +0 -52
- package/dist/utils/Data/getOptions.test.js +0 -71
- package/dist/utils/Data/getSourceData.test.js +0 -141
- package/dist/utils/Data/refDataToOptions.test.js +0 -197
- package/dist/utils/Data/setDataItem.test.js +0 -112
- package/dist/utils/Data/setupFormData.test.js +0 -276
- package/dist/utils/Data/setupRefDataUrlForComponent.test.js +0 -133
- package/dist/utils/FormPage/getFormPage.test.js +0 -205
- package/dist/utils/FormPage/getFormPages.test.js +0 -98
- package/dist/utils/FormPage/getPageActions.test.js +0 -89
- package/dist/utils/FormPage/getParagraphFromText.test.js +0 -29
- package/dist/utils/FormPage/showFormPage.test.js +0 -182
- package/dist/utils/FormPage/showFormPageCYA.test.js +0 -30
- package/dist/utils/FormPage/useComponent.test.js +0 -169
- package/dist/utils/Format/formatData.test.js +0 -46
- package/dist/utils/Format/formatDataForComponent.test.js +0 -161
- package/dist/utils/Format/formatDataForForm.test.js +0 -78
- package/dist/utils/Format/formatDataForPage.test.js +0 -96
- package/dist/utils/Hub/getFormHub.test.js +0 -107
- package/dist/utils/Operate/checkValueIsTruthy.test.js +0 -44
- package/dist/utils/Operate/getIndexOfMatchingValueIn.test.js +0 -159
- package/dist/utils/Operate/persistValueInFormData.test.js +0 -106
- package/dist/utils/Operate/runPageOperations.test.js +0 -107
- package/dist/utils/Operate/setValueInFormData.test.js +0 -46
- package/dist/utils/Operate/shouldRun.test.js +0 -69
- package/dist/utils/Validate/validateCollection.test.js +0 -74
- package/dist/utils/Validate/validateComponent.test.js +0 -267
- package/dist/utils/Validate/validateContainer.test.js +0 -81
- package/dist/utils/Validate/validateDate.test.js +0 -118
- package/dist/utils/Validate/validateEmail.test.js +0 -57
- package/dist/utils/Validate/validatePage.test.js +0 -383
- package/dist/utils/Validate/validateRegex.test.js +0 -41
- package/dist/utils/Validate/validateRequired.test.js +0 -62
- package/dist/utils/Validate/validateTime.test.js +0 -61
|
@@ -4,31 +4,18 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.default = void 0;
|
|
7
|
-
|
|
8
7
|
var _models = require("../../models");
|
|
9
|
-
|
|
10
8
|
var _showComponent = _interopRequireDefault(require("../Component/showComponent"));
|
|
11
|
-
|
|
12
9
|
var _additional = _interopRequireDefault(require("./additional"));
|
|
13
|
-
|
|
14
10
|
var _validateCollection = _interopRequireDefault(require("./validateCollection"));
|
|
15
|
-
|
|
16
11
|
var _validateContainer = _interopRequireDefault(require("./validateContainer"));
|
|
17
|
-
|
|
18
12
|
var _validateDate = _interopRequireDefault(require("./validateDate"));
|
|
19
|
-
|
|
20
13
|
var _validateEmail = _interopRequireDefault(require("./validateEmail"));
|
|
21
|
-
|
|
22
14
|
var _validateRegex = _interopRequireDefault(require("./validateRegex"));
|
|
23
|
-
|
|
24
15
|
var _validateRequired = _interopRequireDefault(require("./validateRequired"));
|
|
25
|
-
|
|
26
16
|
var _validateTime = _interopRequireDefault(require("./validateTime"));
|
|
27
|
-
|
|
28
17
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
29
|
-
|
|
30
18
|
function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) { return typeof obj; } : function (obj) { return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }, _typeof(obj); }
|
|
31
|
-
|
|
32
19
|
/**
|
|
33
20
|
* Validates a single component.
|
|
34
21
|
* @param {object} component The component to validate.
|
|
@@ -38,47 +25,36 @@ function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" =
|
|
|
38
25
|
*/
|
|
39
26
|
var validateComponent = function validateComponent(component, outerData, formData) {
|
|
40
27
|
var _component$data$optio;
|
|
41
|
-
|
|
42
28
|
var fd = formData || outerData;
|
|
43
|
-
|
|
44
29
|
if (!(0, _showComponent.default)(component, fd)) {
|
|
45
30
|
return undefined;
|
|
46
31
|
}
|
|
47
|
-
|
|
48
32
|
if (component.type === _models.ComponentTypes.CONTAINER) {
|
|
49
33
|
return (0, _validateContainer.default)(component, outerData, fd);
|
|
50
34
|
}
|
|
51
|
-
|
|
52
35
|
var error = undefined;
|
|
53
36
|
var properties = undefined;
|
|
54
37
|
var data = outerData && _typeof(outerData) === 'object' ? outerData : {};
|
|
55
38
|
var value = data[component.fieldId];
|
|
56
|
-
|
|
57
39
|
if (component.required) {
|
|
58
40
|
error = (0, _validateRequired.default)(value, component.label, component.custom_errors);
|
|
59
41
|
}
|
|
60
|
-
|
|
61
42
|
if (!error) {
|
|
62
43
|
switch (component.type) {
|
|
63
44
|
case _models.ComponentTypes.COLLECTION:
|
|
64
45
|
return (0, _validateCollection.default)(component, value, fd);
|
|
65
|
-
|
|
66
46
|
case _models.ComponentTypes.EMAIL:
|
|
67
47
|
error = (0, _validateEmail.default)(value, component.label);
|
|
68
48
|
break;
|
|
69
|
-
|
|
70
49
|
case _models.ComponentTypes.DATE:
|
|
71
50
|
case _models.ComponentTypes.TIME:
|
|
72
51
|
var validator = component.type === _models.ComponentTypes.DATE ? _validateDate.default : _validateTime.default;
|
|
73
|
-
|
|
74
52
|
var _validator = validator(value),
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
53
|
+
message = _validator.message,
|
|
54
|
+
propsInError = _validator.propsInError;
|
|
78
55
|
properties = propsInError;
|
|
79
56
|
error = message;
|
|
80
57
|
break;
|
|
81
|
-
|
|
82
58
|
case _models.ComponentTypes.RADIOS:
|
|
83
59
|
var nestedErrors = [];
|
|
84
60
|
(_component$data$optio = component.data.options) === null || _component$data$optio === void 0 ? void 0 : _component$data$optio.forEach(function (option) {
|
|
@@ -88,24 +64,18 @@ var validateComponent = function validateComponent(component, outerData, formDat
|
|
|
88
64
|
}, formData));
|
|
89
65
|
}
|
|
90
66
|
});
|
|
91
|
-
|
|
92
67
|
if (nestedErrors.length > 0) {
|
|
93
68
|
return nestedErrors;
|
|
94
69
|
}
|
|
95
|
-
|
|
96
70
|
break;
|
|
97
|
-
|
|
98
71
|
default:
|
|
99
72
|
break;
|
|
100
73
|
}
|
|
101
|
-
|
|
102
74
|
if (!error && component.pattern) {
|
|
103
75
|
error = (0, _validateRegex.default)(value, component.label, component.pattern, component.custom_errors);
|
|
104
76
|
}
|
|
105
|
-
|
|
106
77
|
if (!error && component.additionalValidation) {
|
|
107
78
|
error = (0, _additional.default)(component, value);
|
|
108
|
-
|
|
109
79
|
if (component.type === _models.ComponentTypes.DATE && error) {
|
|
110
80
|
properties = {
|
|
111
81
|
day: true,
|
|
@@ -115,7 +85,6 @@ var validateComponent = function validateComponent(component, outerData, formDat
|
|
|
115
85
|
}
|
|
116
86
|
}
|
|
117
87
|
}
|
|
118
|
-
|
|
119
88
|
if (error) {
|
|
120
89
|
return {
|
|
121
90
|
id: component.full_path || component.id,
|
|
@@ -123,9 +92,7 @@ var validateComponent = function validateComponent(component, outerData, formDat
|
|
|
123
92
|
properties: properties
|
|
124
93
|
};
|
|
125
94
|
}
|
|
126
|
-
|
|
127
95
|
return undefined;
|
|
128
96
|
};
|
|
129
|
-
|
|
130
97
|
var _default = validateComponent;
|
|
131
98
|
exports.default = _default;
|
|
@@ -4,19 +4,12 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.default = void 0;
|
|
7
|
-
|
|
8
7
|
var _validateComponent = _interopRequireDefault(require("./validateComponent"));
|
|
9
|
-
|
|
10
8
|
var _additional = _interopRequireDefault(require("./additional"));
|
|
11
|
-
|
|
12
9
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
13
|
-
|
|
14
10
|
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
|
|
15
|
-
|
|
16
11
|
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
|
|
17
|
-
|
|
18
12
|
function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
19
|
-
|
|
20
13
|
/**
|
|
21
14
|
* Validates all components within a container.
|
|
22
15
|
* @param {object} container The container to validate.
|
|
@@ -28,19 +21,15 @@ var validateContainer = function validateContainer(container, outerData, formDat
|
|
|
28
21
|
if (!container) {
|
|
29
22
|
return [];
|
|
30
23
|
}
|
|
31
|
-
|
|
32
24
|
var fd = formData || outerData;
|
|
33
25
|
var error = (0, _additional.default)(container, fd);
|
|
34
|
-
|
|
35
26
|
if (error) {
|
|
36
27
|
return {
|
|
37
28
|
id: container.id,
|
|
38
29
|
error: error
|
|
39
30
|
};
|
|
40
31
|
}
|
|
41
|
-
|
|
42
32
|
var errors = [];
|
|
43
|
-
|
|
44
33
|
if (Array.isArray(container.components)) {
|
|
45
34
|
var containerData = outerData && container.fieldId ? outerData[container.fieldId] : outerData;
|
|
46
35
|
container.components.forEach(function (component) {
|
|
@@ -50,11 +39,9 @@ var validateContainer = function validateContainer(container, outerData, formDat
|
|
|
50
39
|
}), containerData, fd));
|
|
51
40
|
});
|
|
52
41
|
}
|
|
53
|
-
|
|
54
42
|
return errors.flat(1).filter(function (e) {
|
|
55
43
|
return !!e;
|
|
56
44
|
});
|
|
57
45
|
};
|
|
58
|
-
|
|
59
46
|
var _default = validateContainer;
|
|
60
47
|
exports.default = _default;
|
|
@@ -4,49 +4,30 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.maxMonthDays = exports.default = void 0;
|
|
7
|
-
|
|
8
7
|
var _dayjs = _interopRequireDefault(require("dayjs"));
|
|
9
|
-
|
|
10
8
|
var _customParseFormat = _interopRequireDefault(require("dayjs/plugin/customParseFormat"));
|
|
11
|
-
|
|
12
9
|
var _isToday = _interopRequireDefault(require("dayjs/plugin/isToday"));
|
|
13
|
-
|
|
14
10
|
var _isLeapYear = _interopRequireDefault(require("dayjs/plugin/isLeapYear"));
|
|
15
|
-
|
|
16
11
|
var _utils = require("./additional/utils");
|
|
17
|
-
|
|
18
12
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
19
|
-
|
|
20
13
|
function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
|
|
21
|
-
|
|
22
14
|
function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
|
|
23
|
-
|
|
24
15
|
function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
|
|
25
|
-
|
|
26
16
|
function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) { arr2[i] = arr[i]; } return arr2; }
|
|
27
|
-
|
|
28
17
|
function _iterableToArrayLimit(arr, i) { var _i = arr == null ? null : typeof Symbol !== "undefined" && arr[Symbol.iterator] || arr["@@iterator"]; if (_i == null) return; var _arr = []; var _n = true; var _d = false; var _s, _e; try { for (_i = _i.call(arr); !(_n = (_s = _i.next()).done); _n = true) { _arr.push(_s.value); if (i && _arr.length === i) break; } } catch (err) { _d = true; _e = err; } finally { try { if (!_n && _i["return"] != null) _i["return"](); } finally { if (_d) throw _e; } } return _arr; }
|
|
29
|
-
|
|
30
18
|
function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
|
|
31
|
-
|
|
32
19
|
_dayjs.default.extend(_customParseFormat.default);
|
|
33
|
-
|
|
34
20
|
_dayjs.default.extend(_isToday.default);
|
|
35
|
-
|
|
36
21
|
_dayjs.default.extend(_isLeapYear.default);
|
|
37
|
-
|
|
38
22
|
var maxMonthDays = function maxMonthDays(month, year) {
|
|
39
23
|
if (month === '02') {
|
|
40
24
|
return (0, _dayjs.default)().year(year).isLeapYear() ? 29 : 28;
|
|
41
25
|
} else if (['04', '06', '09', '11'].includes(month)) {
|
|
42
26
|
return 30;
|
|
43
27
|
}
|
|
44
|
-
|
|
45
28
|
return 31;
|
|
46
29
|
};
|
|
47
|
-
|
|
48
30
|
exports.maxMonthDays = maxMonthDays;
|
|
49
|
-
|
|
50
31
|
/**
|
|
51
32
|
* Checks if a date passed is a valid date.
|
|
52
33
|
* This will validate for 'leap years', missing components, invalid day, monnth or year components.
|
|
@@ -66,18 +47,14 @@ var validateDate = function validateDate(date) {
|
|
|
66
47
|
propsInError: undefined
|
|
67
48
|
};
|
|
68
49
|
}
|
|
69
|
-
|
|
70
50
|
var formattedDate = (0, _utils.formatString)(date);
|
|
71
|
-
|
|
72
51
|
var _formattedDate$split = formattedDate.split('-'),
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
52
|
+
_formattedDate$split2 = _slicedToArray(_formattedDate$split, 3),
|
|
53
|
+
day = _formattedDate$split2[0],
|
|
54
|
+
month = _formattedDate$split2[1],
|
|
55
|
+
year = _formattedDate$split2[2];
|
|
78
56
|
var intDay = parseInt(day, 10);
|
|
79
57
|
var intMonth = parseInt(month, 10);
|
|
80
|
-
|
|
81
58
|
if (year.length === 0) {
|
|
82
59
|
return {
|
|
83
60
|
message: 'Date must include a year',
|
|
@@ -86,7 +63,6 @@ var validateDate = function validateDate(date) {
|
|
|
86
63
|
}
|
|
87
64
|
};
|
|
88
65
|
}
|
|
89
|
-
|
|
90
66
|
if (year.length !== 4) {
|
|
91
67
|
return {
|
|
92
68
|
message: 'Year must be 4 numbers',
|
|
@@ -95,7 +71,6 @@ var validateDate = function validateDate(date) {
|
|
|
95
71
|
}
|
|
96
72
|
};
|
|
97
73
|
}
|
|
98
|
-
|
|
99
74
|
if (month.length === 0) {
|
|
100
75
|
return {
|
|
101
76
|
message: 'Date must include a month',
|
|
@@ -104,7 +79,6 @@ var validateDate = function validateDate(date) {
|
|
|
104
79
|
}
|
|
105
80
|
};
|
|
106
81
|
}
|
|
107
|
-
|
|
108
82
|
if (intMonth > 12 || intMonth < 1) {
|
|
109
83
|
return {
|
|
110
84
|
message: 'Month must be between 1 and 12',
|
|
@@ -113,7 +87,6 @@ var validateDate = function validateDate(date) {
|
|
|
113
87
|
}
|
|
114
88
|
};
|
|
115
89
|
}
|
|
116
|
-
|
|
117
90
|
if (day.length === 0) {
|
|
118
91
|
return {
|
|
119
92
|
message: 'Date must include a day',
|
|
@@ -122,9 +95,7 @@ var validateDate = function validateDate(date) {
|
|
|
122
95
|
}
|
|
123
96
|
};
|
|
124
97
|
}
|
|
125
|
-
|
|
126
98
|
var maxDays = maxMonthDays(month, year);
|
|
127
|
-
|
|
128
99
|
if (intDay > maxDays || intDay < 1) {
|
|
129
100
|
return {
|
|
130
101
|
message: "Day must be between 1 and ".concat(maxDays),
|
|
@@ -133,7 +104,6 @@ var validateDate = function validateDate(date) {
|
|
|
133
104
|
}
|
|
134
105
|
};
|
|
135
106
|
}
|
|
136
|
-
|
|
137
107
|
if ((0, _dayjs.default)(formattedDate, _utils.DATE_FORMAT).format(_utils.DATE_FORMAT) !== formattedDate) {
|
|
138
108
|
return {
|
|
139
109
|
message: 'Enter a valid date',
|
|
@@ -144,12 +114,10 @@ var validateDate = function validateDate(date) {
|
|
|
144
114
|
}
|
|
145
115
|
};
|
|
146
116
|
}
|
|
147
|
-
|
|
148
117
|
return {
|
|
149
118
|
message: undefined,
|
|
150
119
|
propsInError: undefined
|
|
151
120
|
};
|
|
152
121
|
};
|
|
153
|
-
|
|
154
122
|
var _default = validateDate;
|
|
155
123
|
exports.default = _default;
|
|
@@ -4,9 +4,8 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.default = void 0;
|
|
7
|
-
// eslint-disable-next-line no-control-regex
|
|
8
|
-
// const EMAIL_REGEX = /(?:[a-z0-9!#$%&'*+/=?^_`{|}~-]+(?:\.[a-z0-9!#$%&'*+/=?^_`{|}~-]+)*|"(?:[\x01-\x08\x0b\x0c\x0e-\x1f\x21\x23-\x5b\x5d-\x7f]|\\[\x01-\x09\x0b\x0c\x0e-\x7f])*")@(?:(?:[a-z0-9](?:[a-z0-9-]*[a-z0-9])?\.)+[a-z0-9](?:[a-z0-9-]*[a-z0-9])?|\[(?:(?:(2(5[0-5]|[0-4][0-9])|1[0-9][0-9]|[1-9]?[0-9]))\.){3}(?:(2(5[0-5]|[0-4][0-9])|1[0-9][0-9]|[1-9]?[0-9])|[a-z0-9-]*[a-z0-9]:(?:[\x01-\x08\x0b\x0c\x0e-\x1f\x21-\x5a\x53-\x7f]|\\[\x01-\x09\x0b\x0c\x0e-\x7f])+)\])/i;
|
|
9
7
|
var HODS_EMAIL_REGEX = /^[a-z0-9._-]+@(digital\.)?homeoffice.gov.uk$/i;
|
|
8
|
+
|
|
10
9
|
/**
|
|
11
10
|
* Validates an email address, ensuring it is in the correct domain and
|
|
12
11
|
* complies with the Home Office email address standards.
|
|
@@ -17,23 +16,18 @@ var HODS_EMAIL_REGEX = /^[a-z0-9._-]+@(digital\.)?homeoffice.gov.uk$/i;
|
|
|
17
16
|
* @param {string} label The label to use in any error message.
|
|
18
17
|
* @returns An error if the email address is invalid.
|
|
19
18
|
*/
|
|
20
|
-
|
|
21
19
|
var validateEmail = function validateEmail(value) {
|
|
22
20
|
var label = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : '';
|
|
23
|
-
|
|
24
21
|
if (!!value) {
|
|
25
22
|
if (typeof value === 'string') {
|
|
26
23
|
if (HODS_EMAIL_REGEX.test(value)) {
|
|
27
24
|
return undefined;
|
|
28
25
|
}
|
|
29
26
|
}
|
|
30
|
-
|
|
31
27
|
var name = label ? label.toLowerCase() : 'email address';
|
|
32
28
|
return "Enter ".concat(name, " in the correct format, like jane.doe@homeoffice.gov.uk");
|
|
33
29
|
}
|
|
34
|
-
|
|
35
30
|
return undefined;
|
|
36
31
|
};
|
|
37
|
-
|
|
38
32
|
var _default = validateEmail;
|
|
39
33
|
exports.default = _default;
|
|
@@ -4,23 +4,14 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.default = void 0;
|
|
7
|
-
|
|
8
7
|
var _copReactComponents = require("@ukhomeoffice/cop-react-components");
|
|
9
|
-
|
|
10
8
|
var _validateComponent = _interopRequireDefault(require("./validateComponent"));
|
|
11
|
-
|
|
12
9
|
var _CollectionPage = _interopRequireDefault(require("../CollectionPage"));
|
|
13
|
-
|
|
14
10
|
var _showFormPage = _interopRequireDefault(require("../FormPage/showFormPage"));
|
|
15
|
-
|
|
16
11
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
17
|
-
|
|
18
12
|
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
|
|
19
|
-
|
|
20
13
|
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
|
|
21
|
-
|
|
22
14
|
function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
23
|
-
|
|
24
15
|
/**
|
|
25
16
|
* Validate all of the components on a page.
|
|
26
17
|
* @param {object} page The page to validate
|
|
@@ -28,17 +19,13 @@ function _defineProperty(obj, key, value) { if (key in obj) { Object.definePrope
|
|
|
28
19
|
*/
|
|
29
20
|
var validatePage = function validatePage(page) {
|
|
30
21
|
var data = page.formData;
|
|
31
|
-
|
|
32
22
|
if (page.collection) {
|
|
33
23
|
var activeIndex = _CollectionPage.default.getActiveIndex(page.collection.name, page.formData);
|
|
34
|
-
|
|
35
24
|
if (activeIndex !== null) {
|
|
36
25
|
var _page$formData$page$c;
|
|
37
|
-
|
|
38
26
|
data = (_page$formData$page$c = page.formData[page.collection.name]) === null || _page$formData$page$c === void 0 ? void 0 : _page$formData$page$c[activeIndex];
|
|
39
27
|
}
|
|
40
28
|
}
|
|
41
|
-
|
|
42
29
|
if ((0, _showFormPage.default)(page, page.formData) && Array.isArray(page.components)) {
|
|
43
30
|
var errs = page.components.reduce(function (errors, component) {
|
|
44
31
|
var componentErrors = (0, _validateComponent.default)(component, data, data);
|
|
@@ -52,9 +39,7 @@ var validatePage = function validatePage(page) {
|
|
|
52
39
|
}).flat();
|
|
53
40
|
return errs;
|
|
54
41
|
}
|
|
55
|
-
|
|
56
42
|
return [];
|
|
57
43
|
};
|
|
58
|
-
|
|
59
44
|
var _default = validatePage;
|
|
60
45
|
exports.default = _default;
|
|
@@ -4,7 +4,6 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.default = void 0;
|
|
7
|
-
|
|
8
7
|
/**
|
|
9
8
|
* Validates an components value against a given regex pattern.
|
|
10
9
|
*
|
|
@@ -20,37 +19,28 @@ var validateRegex = function validateRegex(value) {
|
|
|
20
19
|
var label = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : '';
|
|
21
20
|
var pattern = arguments.length > 2 ? arguments[2] : undefined;
|
|
22
21
|
var customErrors = arguments.length > 3 ? arguments[3] : undefined;
|
|
23
|
-
|
|
24
22
|
if (!value) {
|
|
25
23
|
return undefined;
|
|
26
24
|
}
|
|
27
|
-
|
|
28
25
|
if (typeof value === 'string') {
|
|
29
26
|
var regex = new RegExp(pattern);
|
|
30
|
-
|
|
31
27
|
if (regex.test(value)) {
|
|
32
28
|
return undefined;
|
|
33
29
|
}
|
|
34
|
-
|
|
35
30
|
if (Array.isArray(customErrors)) {
|
|
36
31
|
var _result$;
|
|
37
|
-
|
|
38
32
|
var result = customErrors.filter(function (error) {
|
|
39
33
|
return error.type === 'pattern';
|
|
40
34
|
});
|
|
41
|
-
|
|
42
35
|
if (result !== null && result !== void 0 && (_result$ = result[0]) !== null && _result$ !== void 0 && _result$.message) {
|
|
43
36
|
return result[0].message;
|
|
44
37
|
}
|
|
45
38
|
}
|
|
46
39
|
}
|
|
47
|
-
|
|
48
40
|
if (label === '') {
|
|
49
41
|
return 'Component failed regex validation';
|
|
50
42
|
}
|
|
51
|
-
|
|
52
43
|
return "".concat(label, " failed regex validation");
|
|
53
44
|
};
|
|
54
|
-
|
|
55
45
|
var _default = validateRegex;
|
|
56
46
|
exports.default = _default;
|
|
@@ -4,7 +4,6 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.default = void 0;
|
|
7
|
-
|
|
8
7
|
/**
|
|
9
8
|
* Validates that a value is not nullish, which includes ensuring
|
|
10
9
|
* a string isn't just whitespace, an array is not empty, etc.
|
|
@@ -16,34 +15,27 @@ var validateRequired = function validateRequired(value) {
|
|
|
16
15
|
var label = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : '';
|
|
17
16
|
var customErrors = arguments.length > 2 ? arguments[2] : undefined;
|
|
18
17
|
var hasValue = false;
|
|
19
|
-
|
|
20
18
|
if (!!value || value === false || value === 0) {
|
|
21
19
|
hasValue = true;
|
|
22
|
-
|
|
23
20
|
if (typeof value === 'string') {
|
|
24
21
|
hasValue = value.trim().length > 0;
|
|
25
22
|
} else if (Array.isArray(value)) {
|
|
26
23
|
hasValue = value.length > 0;
|
|
27
24
|
}
|
|
28
25
|
}
|
|
29
|
-
|
|
30
26
|
if (!hasValue) {
|
|
31
27
|
if (Array.isArray(customErrors)) {
|
|
32
28
|
var result = customErrors.filter(function (error) {
|
|
33
29
|
return error.type === 'required';
|
|
34
30
|
});
|
|
35
|
-
|
|
36
31
|
if (result && result.length > 0 && result[0].message) {
|
|
37
32
|
return result[0].message;
|
|
38
33
|
}
|
|
39
34
|
}
|
|
40
|
-
|
|
41
35
|
var name = label ? label : 'Field';
|
|
42
36
|
return "".concat(name, " is required");
|
|
43
37
|
}
|
|
44
|
-
|
|
45
38
|
return undefined;
|
|
46
39
|
};
|
|
47
|
-
|
|
48
40
|
var _default = validateRequired;
|
|
49
41
|
exports.default = _default;
|
|
@@ -4,21 +4,13 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.default = void 0;
|
|
7
|
-
|
|
8
7
|
var _utils = require("./additional/utils");
|
|
9
|
-
|
|
10
8
|
function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
|
|
11
|
-
|
|
12
9
|
function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
|
|
13
|
-
|
|
14
10
|
function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
|
|
15
|
-
|
|
16
11
|
function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) { arr2[i] = arr[i]; } return arr2; }
|
|
17
|
-
|
|
18
12
|
function _iterableToArrayLimit(arr, i) { var _i = arr == null ? null : typeof Symbol !== "undefined" && arr[Symbol.iterator] || arr["@@iterator"]; if (_i == null) return; var _arr = []; var _n = true; var _d = false; var _s, _e; try { for (_i = _i.call(arr); !(_n = (_s = _i.next()).done); _n = true) { _arr.push(_s.value); if (i && _arr.length === i) break; } } catch (err) { _d = true; _e = err; } finally { try { if (!_n && _i["return"] != null) _i["return"](); } finally { if (_d) throw _e; } } return _arr; }
|
|
19
|
-
|
|
20
13
|
function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
|
|
21
|
-
|
|
22
14
|
/**
|
|
23
15
|
* Checks if a time passed is a valid time.
|
|
24
16
|
* This will validate for missing components, invalid hour or minute components.
|
|
@@ -38,17 +30,13 @@ var validateTime = function validateTime(time) {
|
|
|
38
30
|
propsInError: undefined
|
|
39
31
|
};
|
|
40
32
|
}
|
|
41
|
-
|
|
42
33
|
var formattedDate = (0, _utils.formattedTime)(time);
|
|
43
|
-
|
|
44
34
|
var _formattedDate$split = formattedDate.split(':'),
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
35
|
+
_formattedDate$split2 = _slicedToArray(_formattedDate$split, 2),
|
|
36
|
+
hour = _formattedDate$split2[0],
|
|
37
|
+
minute = _formattedDate$split2[1];
|
|
49
38
|
var intHour = parseInt(hour, 10);
|
|
50
39
|
var intMinute = parseInt(minute, 10);
|
|
51
|
-
|
|
52
40
|
if (hour.length === 0) {
|
|
53
41
|
return {
|
|
54
42
|
message: 'Time must include a hour',
|
|
@@ -57,7 +45,6 @@ var validateTime = function validateTime(time) {
|
|
|
57
45
|
}
|
|
58
46
|
};
|
|
59
47
|
}
|
|
60
|
-
|
|
61
48
|
if (intHour > 23 || intHour < 0) {
|
|
62
49
|
return {
|
|
63
50
|
message: 'Hour must be between 0 and 23',
|
|
@@ -66,7 +53,6 @@ var validateTime = function validateTime(time) {
|
|
|
66
53
|
}
|
|
67
54
|
};
|
|
68
55
|
}
|
|
69
|
-
|
|
70
56
|
if (minute.length === 0) {
|
|
71
57
|
return {
|
|
72
58
|
message: 'Time must include a minute',
|
|
@@ -75,7 +61,6 @@ var validateTime = function validateTime(time) {
|
|
|
75
61
|
}
|
|
76
62
|
};
|
|
77
63
|
}
|
|
78
|
-
|
|
79
64
|
if (intMinute > 59 || intMinute < 0) {
|
|
80
65
|
return {
|
|
81
66
|
message: 'Minute must be between 0 and 59',
|
|
@@ -84,12 +69,10 @@ var validateTime = function validateTime(time) {
|
|
|
84
69
|
}
|
|
85
70
|
};
|
|
86
71
|
}
|
|
87
|
-
|
|
88
72
|
return {
|
|
89
73
|
message: undefined,
|
|
90
74
|
propsInError: undefined
|
|
91
75
|
};
|
|
92
76
|
};
|
|
93
|
-
|
|
94
77
|
var _default = validateTime;
|
|
95
78
|
exports.default = _default;
|
package/dist/utils/index.js
CHANGED
|
@@ -4,41 +4,23 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.default = void 0;
|
|
7
|
-
|
|
8
7
|
var _copReactComponents = require("@ukhomeoffice/cop-react-components");
|
|
9
|
-
|
|
10
8
|
var _CheckYourAnswers = _interopRequireDefault(require("./CheckYourAnswers"));
|
|
11
|
-
|
|
12
9
|
var _Component = _interopRequireDefault(require("./Component"));
|
|
13
|
-
|
|
14
10
|
var _CollectionPage = _interopRequireDefault(require("./CollectionPage"));
|
|
15
|
-
|
|
16
11
|
var _Condition = _interopRequireDefault(require("./Condition"));
|
|
17
|
-
|
|
18
12
|
var _Container = _interopRequireDefault(require("./Container"));
|
|
19
|
-
|
|
20
13
|
var _Data = _interopRequireDefault(require("./Data"));
|
|
21
|
-
|
|
22
14
|
var _Format = _interopRequireDefault(require("./Format"));
|
|
23
|
-
|
|
24
15
|
var _FormPage = _interopRequireDefault(require("./FormPage"));
|
|
25
|
-
|
|
26
16
|
var _Hub = _interopRequireDefault(require("./Hub"));
|
|
27
|
-
|
|
28
17
|
var _Meta = _interopRequireDefault(require("./Meta"));
|
|
29
|
-
|
|
30
18
|
var _Operate = _interopRequireDefault(require("./Operate"));
|
|
31
|
-
|
|
32
19
|
var _Validate = _interopRequireDefault(require("./Validate"));
|
|
33
|
-
|
|
34
20
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
35
|
-
|
|
36
21
|
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
|
|
37
|
-
|
|
38
22
|
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
|
|
39
|
-
|
|
40
23
|
function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
41
|
-
|
|
42
24
|
var Utils = _objectSpread({
|
|
43
25
|
CheckYourAnswers: _CheckYourAnswers.default,
|
|
44
26
|
CollectionPage: _CollectionPage.default,
|
|
@@ -53,6 +35,5 @@ var Utils = _objectSpread({
|
|
|
53
35
|
Operate: _Operate.default,
|
|
54
36
|
Validate: _Validate.default
|
|
55
37
|
}, _copReactComponents.Utils);
|
|
56
|
-
|
|
57
38
|
var _default = Utils;
|
|
58
39
|
exports.default = _default;
|