@wise/dynamic-flow-client 0.4.0 → 0.4.2
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/build/common/constants/DateMode.js +2 -2
- package/build/common/constants/FormControlType.js +2 -2
- package/build/common/constants/MonthFormat.js +2 -2
- package/build/common/constants/SchemaType.js +2 -2
- package/build/common/constants/Size.js +2 -2
- package/build/common/constants/index.js +1 -1
- package/build/common/contexts/dynamicFlowContexts/DynamicFlowContexts.js +15 -27
- package/build/common/contexts/dynamicFlowContexts/usePendingPromiseCounter.js +11 -9
- package/build/common/contexts/eventsContext/EventsContext.js +11 -28
- package/build/common/contexts/fetcherContexts/FetcherContexts.js +14 -27
- package/build/common/contexts/index.js +1 -1
- package/build/common/contexts/logContext/LogContext.js +12 -30
- package/build/common/hooks/index.js +1 -1
- package/build/common/hooks/useDebouncedFunction/useDebouncedFunction.js +3 -3
- package/build/common/hooks/useExternal/useExternal.js +8 -8
- package/build/common/hooks/useExternalStepPolling/useExternalStepPolling.js +20 -31
- package/build/common/hooks/usePersistAsync/usePersistAsync.js +60 -139
- package/build/common/hooks/usePolling/usePolling.js +20 -21
- package/build/common/hooks/usePrevious/usePrevious.js +5 -5
- package/build/common/hooks/useStepPolling/useStepPolling.js +15 -14
- package/build/common/makeFetcher/index.js +1 -1
- package/build/common/makeFetcher/makeFetcher.js +10 -24
- package/build/common/messages.js +5 -5
- package/build/common/utils/api-utils.js +3 -4
- package/build/common/utils/date-utils.js +11 -11
- package/build/common/utils/debounce.js +11 -15
- package/build/common/utils/file-utils.js +12 -25
- package/build/common/utils/id-utils.js +4 -5
- package/build/common/utils/index.js +1 -1
- package/build/common/utils/is-equal.js +8 -8
- package/build/common/utils/schema-utils.js +6 -6
- package/build/common/utils/step-utils.js +14 -14
- package/build/common/validators/index.js +7 -7
- package/build/common/validators/models/model-validators.js +8 -8
- package/build/common/validators/models/models.utils.js +29 -42
- package/build/common/validators/schemas/schema-validators.js +11 -13
- package/build/common/validators/types/type-validators.js +9 -13
- package/build/common/validators/validationFailures/validation-failures.js +14 -14
- package/build/common/validators/validationFailures/validation-failures.utils.js +5 -7
- package/build/common/validators/values/value-validators.js +4 -6
- package/build/dynamicFlow/DynamicFlow.js +185 -307
- package/build/dynamicFlow/DynamicFlowStep.js +12 -23
- package/build/dynamicFlow/DynamicFlowTypes.js +1 -1
- package/build/dynamicFlow/index.js +6 -14
- package/build/dynamicFlow/stories/DynamicFlow.story.js +20 -20
- package/build/dynamicFlow/stories/EditableDynamicFlow.js +20 -33
- package/build/dynamicFlow/stories/fixtureFetcher.js +46 -104
- package/build/dynamicFlow/utils/errorBoundary/ErrorBoundary.js +22 -40
- package/build/dynamicFlow/utils/errorBoundary/ErrorBoundary.messages.js +6 -6
- package/build/dynamicFlow/utils/errorBoundary/ErrorBoundaryAlert.js +10 -11
- package/build/dynamicFlow/utils/index.js +5 -2
- package/build/dynamicFlow/utils/responseParsers/response-parsers.js +53 -118
- package/build/dynamicFlow/utils/useDebouncedRefresh/useDebouncedRefresh.js +9 -9
- package/build/dynamicFlow/utils/useDynamicFlowState.js +51 -74
- package/build/dynamicFlow/utils/useLoader.js +9 -20
- package/build/fixtures/components/alert.js +8 -8
- package/build/fixtures/components/box.js +7 -7
- package/build/fixtures/components/button.js +25 -36
- package/build/fixtures/components/columns.js +10 -10
- package/build/fixtures/components/copyable.js +6 -6
- package/build/fixtures/components/decision.js +15 -15
- package/build/fixtures/components/heading.js +7 -7
- package/build/fixtures/components/image.js +10 -10
- package/build/fixtures/components/index.js +17 -25
- package/build/fixtures/components/info.js +22 -6
- package/build/fixtures/components/list.js +8 -8
- package/build/fixtures/components/loading-indicator.js +5 -5
- package/build/fixtures/components/paragraph.js +9 -9
- package/build/fixtures/components/review.js +11 -11
- package/build/fixtures/examples/camera-capture.js +29 -29
- package/build/fixtures/examples/index.js +9 -17
- package/build/fixtures/examples/recipient-update.js +69 -69
- package/build/fixtures/examples/recipient.js +63 -63
- package/build/fixtures/examples/single-file-upload.js +21 -21
- package/build/fixtures/examples/step-validation-errors.js +21 -21
- package/build/fixtures/features/action-response.js +8 -8
- package/build/fixtures/features/external.js +8 -8
- package/build/fixtures/features/index.js +9 -17
- package/build/fixtures/features/persist-async.js +11 -11
- package/build/fixtures/features/polling.js +9 -9
- package/build/fixtures/features/validation-async.js +10 -10
- package/build/fixtures/index.js +11 -22
- package/build/fixtures/jsonSchemaForm/allOf.js +30 -30
- package/build/fixtures/jsonSchemaForm/audRecipient.js +271 -271
- package/build/fixtures/jsonSchemaForm/currency.js +12 -12
- package/build/fixtures/jsonSchemaForm/multipleFileUploadBase64.js +11 -11
- package/build/fixtures/jsonSchemaForm/multipleFileUploadBlob.js +11 -11
- package/build/fixtures/jsonSchemaForm/oneOf.js +27 -27
- package/build/fixtures/jsonSchemaForm/oneOfTabs.js +16 -16
- package/build/fixtures/jsonSchemaForm/promotedOneOf.js +17 -17
- package/build/fixtures/jsonSchemaForm/promotedOneOfCheckbox.js +30 -30
- package/build/fixtures/jsonSchemaForm/simple.js +16 -16
- package/build/fixtures/jsonSchemaForm/uploadPersistAsync.js +19 -19
- package/build/fixtures/jsonSchemaForm/validationAsync.js +8 -8
- package/build/fixtures/layouts/all.js +37 -37
- package/build/fixtures/layouts/final-step-layout.js +9 -9
- package/build/fixtures/layouts/index.js +10 -18
- package/build/fixtures/layouts/list.js +10 -10
- package/build/fixtures/layouts/pay-in.js +23 -23
- package/build/fixtures/layouts/review.js +38 -38
- package/build/fixtures/layouts/success.js +15 -15
- package/build/fixtures/responses/action-response-final.js +8 -8
- package/build/fixtures/responses/action.js +3 -3
- package/build/fixtures/responses/exit.js +3 -3
- package/build/fixtures/responses/index.js +8 -16
- package/build/fixtures/responses/recipient-update-final.js +8 -8
- package/build/fixtures/schemas/basic-form.js +11 -11
- package/build/fixtures/schemas/index.js +8 -16
- package/build/fixtures/schemas/number-and-integer.js +11 -11
- package/build/fixtures/schemas/one-of.js +43 -46
- package/build/fixtures/schemas/string-formats.js +15 -15
- package/build/fixtures/utils/image-util.js +8 -8
- package/build/formControl/FormControl.js +118 -148
- package/build/formControl/index.js +6 -14
- package/build/formControl/utils/index.js +1 -1
- package/build/formControl/utils/value-utils.js +18 -23
- package/build/i18n/index.js +31 -31
- package/build/index.js +13 -10
- package/build/jsonSchemaForm/JsonSchemaForm.js +12 -24
- package/build/jsonSchemaForm/allOfSchema/AllOfSchema.js +24 -37
- package/build/jsonSchemaForm/allOfSchema/index.js +6 -14
- package/build/jsonSchemaForm/arrayTypeSchema/ArraySchema.js +9 -20
- package/build/jsonSchemaForm/arrayTypeSchema/arrayListSchema/ArrayListSchema.js +9 -20
- package/build/jsonSchemaForm/arrayTypeSchema/arrayListSchema/index.js +6 -14
- package/build/jsonSchemaForm/arrayTypeSchema/arrayListSchema/multipleFileUploadSchema/MultipleFileUploadSchema.js +56 -115
- package/build/jsonSchemaForm/arrayTypeSchema/arrayListSchema/multipleFileUploadSchema/MultipleFileUploadSchema.messages.js +7 -7
- package/build/jsonSchemaForm/arrayTypeSchema/arrayListSchema/multipleFileUploadSchema/index.js +6 -14
- package/build/jsonSchemaForm/arrayTypeSchema/arrayListSchema/multipleFileUploadSchema/utils/index.js +1 -1
- package/build/jsonSchemaForm/arrayTypeSchema/arrayListSchema/multipleFileUploadSchema/utils/upload-utils.js +19 -71
- package/build/jsonSchemaForm/arrayTypeSchema/arrayListSchema/multipleFileUploadSchema/utils/useFormattedDefaultErrorMessages.js +10 -11
- package/build/jsonSchemaForm/arrayTypeSchema/index.js +6 -14
- package/build/jsonSchemaForm/basicTypeSchema/BasicTypeSchema.js +45 -62
- package/build/jsonSchemaForm/basicTypeSchema/index.js +6 -14
- package/build/jsonSchemaForm/controlFeedback/ControlFeedback.js +39 -50
- package/build/jsonSchemaForm/controlFeedback/ControlFeedback.messages.js +18 -18
- package/build/jsonSchemaForm/controlFeedback/index.js +6 -14
- package/build/jsonSchemaForm/genericSchema/GenericSchema.js +52 -61
- package/build/jsonSchemaForm/genericSchema/index.js +6 -14
- package/build/jsonSchemaForm/help/Help.js +9 -9
- package/build/jsonSchemaForm/help/Help.messages.js +5 -5
- package/build/jsonSchemaForm/help/index.js +6 -14
- package/build/jsonSchemaForm/index.js +6 -14
- package/build/jsonSchemaForm/objectSchema/ObjectSchema.js +28 -49
- package/build/jsonSchemaForm/objectSchema/index.js +6 -14
- package/build/jsonSchemaForm/oneOfSchema/OneOfSchema.js +54 -74
- package/build/jsonSchemaForm/oneOfSchema/index.js +6 -14
- package/build/jsonSchemaForm/oneOfSchema/utils/const-schema-utils.js +3 -3
- package/build/jsonSchemaForm/oneOfSchema/utils/index.js +1 -1
- package/build/jsonSchemaForm/oneOfSchema/utils/one-of-utils.js +19 -20
- package/build/jsonSchemaForm/persistAsyncSchema/PersistAsyncSchema.js +11 -22
- package/build/jsonSchemaForm/persistAsyncSchema/PersistAsyncSchema.messages.js +5 -5
- package/build/jsonSchemaForm/persistAsyncSchema/index.js +6 -14
- package/build/jsonSchemaForm/persistAsyncSchema/persistAsyncBasicSchema/PersistAsyncBasicSchema.js +73 -127
- package/build/jsonSchemaForm/persistAsyncSchema/persistAsyncBasicSchema/index.js +6 -14
- package/build/jsonSchemaForm/persistAsyncSchema/persistAsyncBlobSchema/PersistAsyncBlobSchema.js +45 -110
- package/build/jsonSchemaForm/persistAsyncSchema/persistAsyncBlobSchema/UploadInputAdapter.js +17 -17
- package/build/jsonSchemaForm/persistAsyncSchema/persistAsyncBlobSchema/index.js +6 -14
- package/build/jsonSchemaForm/promotedOneOfSchema/PromotedOneOfSchema.js +28 -47
- package/build/jsonSchemaForm/promotedOneOfSchema/index.js +6 -14
- package/build/jsonSchemaForm/promotedOneOfSchema/promoted-one-of-utils.js +4 -4
- package/build/jsonSchemaForm/promotedOneOfSchema/promotedOneOfControl/PromotedOneOfCheckboxControl.js +13 -24
- package/build/jsonSchemaForm/promotedOneOfSchema/promotedOneOfControl/PromotedOneOfControl.js +11 -22
- package/build/jsonSchemaForm/promotedOneOfSchema/promotedOneOfControl/PromotedOneOfRadioControl.js +12 -23
- package/build/jsonSchemaForm/readOnlySchema/ReadOnlySchema.js +24 -26
- package/build/jsonSchemaForm/readOnlySchema/ReadOnlySchema.messages.js +6 -6
- package/build/jsonSchemaForm/readOnlySchema/index.js +6 -14
- package/build/jsonSchemaForm/schemaFormControl/SchemaFormControl.js +26 -39
- package/build/jsonSchemaForm/schemaFormControl/index.js +6 -14
- package/build/jsonSchemaForm/schemaFormControl/utils/currency-utils.js +5 -5
- package/build/jsonSchemaForm/schemaFormControl/utils/index.js +1 -1
- package/build/jsonSchemaForm/schemaFormControl/utils/mapping-utils.js +30 -47
- package/build/jsonSchemaForm/validationAsyncSchema/ValidationAsyncSchema.js +57 -119
- package/build/jsonSchemaForm/validationAsyncSchema/index.js +6 -14
- package/build/layout/DynamicLayout.js +10 -21
- package/build/layout/alert/DynamicAlert.js +9 -9
- package/build/layout/box/DynamicBox.js +12 -23
- package/build/layout/button/DynamicButton.js +16 -27
- package/build/layout/columns/DynamicColumns.js +13 -24
- package/build/layout/decision/DynamicDecision.js +16 -27
- package/build/layout/divider/DynamicDivider.js +7 -8
- package/build/layout/external/DynamicExternal.js +16 -28
- package/build/layout/external/DynamicExternal.messages.js +5 -5
- package/build/layout/form/DynamicForm.js +10 -21
- package/build/layout/heading/DynamicHeading.js +12 -23
- package/build/layout/icon/DynamicIcon.js +9 -10
- package/build/layout/image/DynamicImage.js +43 -93
- package/build/layout/index.js +21 -29
- package/build/layout/info/DynamicInfo.js +7 -19
- package/build/layout/list/DynamicList.js +14 -26
- package/build/layout/loadingIndicator/DynamicLoadingIndicator.js +8 -9
- package/build/layout/paragraph/DynamicParagraph.js +19 -37
- package/build/layout/paragraph/DynamicParagraph.messages.js +6 -6
- package/build/layout/paragraph/useSnackBarIfAvailable.js +4 -4
- package/build/layout/review/DynamicReview.js +14 -26
- package/build/layout/utils.js +4 -6
- package/build/step/cameraStep/CameraStep.js +42 -88
- package/build/step/cameraStep/cameraCapture/CameraCapture.js +48 -105
- package/build/step/cameraStep/cameraCapture/CameraCapture.messages.js +7 -7
- package/build/step/cameraStep/cameraCapture/components/index.js +10 -28
- package/build/step/cameraStep/cameraCapture/hooks/index.js +17 -72
- package/build/step/cameraStep/cameraCapture/index.js +6 -14
- package/build/step/cameraStep/cameraCapture/overlay/Overlay.js +33 -45
- package/build/step/cameraStep/cameraCapture/screens/CameraNotSupported/CameraNotSupported.js +8 -19
- package/build/step/cameraStep/cameraCapture/screens/CameraNotSupported/CameraNotSupported.messages.js +6 -6
- package/build/step/cameraStep/cameraCapture/screens/NoCameraAccess/NoCameraAccess.js +9 -21
- package/build/step/cameraStep/cameraCapture/screens/NoCameraAccess/NoCameraAccess.messages.js +7 -7
- package/build/step/cameraStep/cameraCapture/screens/index.js +6 -14
- package/build/step/cameraStep/cameraCapture/tracking/index.js +17 -99
- package/build/step/cameraStep/cameraCapture/utils/index.js +33 -96
- package/build/step/cameraStep/index.js +6 -14
- package/build/step/externalConfirmationStep/ExternalConfirmationStep.js +20 -21
- package/build/step/externalConfirmationStep/ExternalConfirmationStep.messages.js +8 -8
- package/build/step/externalConfirmationStep/index.js +6 -14
- package/build/step/index.js +7 -15
- package/build/step/layoutStep/LayoutStep.js +19 -19
- package/build/step/layoutStep/index.js +6 -14
- package/build/step/layoutStep/utils/index.js +3 -14
- package/build/step/layoutStep/utils/inline-reference-utils.js +29 -46
- package/build/step/layoutStep/utils/layout-utils.js +34 -53
- package/build/types/common/FormControl.js +1 -1
- package/build/types/index.js +13 -13
- package/build/types/specification/Action.js +1 -1
- package/build/types/specification/FileUploadSchema.js +1 -1
- package/build/types/specification/LayoutComponent.js +1 -1
- package/build/types/specification/Model.js +9 -17
- package/build/types/specification/PersistAsync.js +1 -1
- package/build/types/specification/Polling.js +1 -1
- package/build/types/specification/Promotion.js +1 -1
- package/build/types/specification/Schema.js +8 -8
- package/build/types/specification/Step.js +3 -5
- package/build/types/specification/ValidationAsync.js +1 -1
- package/build/types/specification/core.js +1 -1
- package/package.json +1 -1
|
@@ -13,7 +13,7 @@ var __createBinding = (this && this.__createBinding) || (Object.create ? (functi
|
|
|
13
13
|
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
14
|
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
15
|
};
|
|
16
|
-
exports
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
17
|
__exportStar(require("./api-utils"), exports);
|
|
18
18
|
__exportStar(require("./date-utils"), exports);
|
|
19
19
|
__exportStar(require("./debounce"), exports);
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
exports
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.isEqual = void 0;
|
|
4
|
-
|
|
4
|
+
const isEqual = (a, b) => {
|
|
5
5
|
if (a === b) {
|
|
6
6
|
return true;
|
|
7
7
|
}
|
|
8
8
|
if (Array.isArray(a) && Array.isArray(b)) {
|
|
9
|
-
return a.length === b.length && a.every(
|
|
9
|
+
return a.length === b.length && a.every((item, index) => (0, exports.isEqual)(item, b[index]));
|
|
10
10
|
}
|
|
11
11
|
if (isNonNullObject(a) && isNonNullObject(b) && isObjectEquals(a, b)) {
|
|
12
12
|
return true;
|
|
@@ -14,12 +14,12 @@ var isEqual = function (a, b) {
|
|
|
14
14
|
return false;
|
|
15
15
|
};
|
|
16
16
|
exports.isEqual = isEqual;
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
17
|
+
const isObjectEquals = (a, b) => {
|
|
18
|
+
const keysA = Object.keys(a);
|
|
19
|
+
const keysB = Object.keys(b);
|
|
20
20
|
return (keysA.length === keysB.length &&
|
|
21
|
-
keysA.every(
|
|
21
|
+
keysA.every((key) => Object.prototype.hasOwnProperty.call(b, key) && (0, exports.isEqual)(a[key], b[key])));
|
|
22
22
|
};
|
|
23
|
-
|
|
23
|
+
const isNonNullObject = (a) => {
|
|
24
24
|
return typeof a === 'object' && a !== null;
|
|
25
25
|
};
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
exports
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.shouldDebounceSchema = exports.getSchemaType = exports.isAllOfSchema = exports.isOneOfSchema = exports.isPromotedOneOfSchema = exports.isReadOnlySchema = void 0;
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
4
|
+
const types_1 = require("../../types");
|
|
5
|
+
const constants_1 = require("../constants");
|
|
6
|
+
const isReadOnlySchema = (schema) => !!schema.readOnly && (0, types_1.isBasicSchema)(schema);
|
|
7
7
|
exports.isReadOnlySchema = isReadOnlySchema;
|
|
8
|
-
|
|
8
|
+
const isPromotedOneOfSchema = (schema) => !!schema.oneOf && !!schema.promotion;
|
|
9
9
|
exports.isPromotedOneOfSchema = isPromotedOneOfSchema;
|
|
10
10
|
/**
|
|
11
11
|
* @deprecated Please use isOneOfSchema type guard function from "dynamic-flow-types"
|
|
@@ -15,7 +15,7 @@ exports.isOneOfSchema = types_1.isOneOfSchema;
|
|
|
15
15
|
* @deprecated Please use isAllOfSchema type guard function from "dynamic-flow-types"
|
|
16
16
|
*/
|
|
17
17
|
exports.isAllOfSchema = types_1.isAllOfSchema;
|
|
18
|
-
|
|
18
|
+
const getSchemaType = (schema) => {
|
|
19
19
|
// Order of application is important here
|
|
20
20
|
if ((0, exports.isReadOnlySchema)(schema)) {
|
|
21
21
|
return constants_1.SchemaType.READ_ONLY;
|
|
@@ -1,44 +1,44 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
exports
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.getStepType = exports.filterHiddenSchemas = exports.stepType = void 0;
|
|
4
|
-
|
|
4
|
+
const types_1 = require("../../types");
|
|
5
5
|
exports.stepType = {
|
|
6
6
|
LAYOUT: 'layout',
|
|
7
|
-
CAMERA: 'camera'
|
|
7
|
+
CAMERA: 'camera',
|
|
8
8
|
};
|
|
9
|
-
|
|
9
|
+
const isCameraStep = (step) => {
|
|
10
10
|
return isFormStep(step) && hasSingleAction(step) && hasSingleFileUploadSchemaWithCameraOnly(step);
|
|
11
11
|
};
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
12
|
+
const isFormStep = (step) => (step === null || step === void 0 ? void 0 : step.type) === 'form';
|
|
13
|
+
const hasSingleAction = (step) => { var _a; return ((_a = step === null || step === void 0 ? void 0 : step.actions) === null || _a === void 0 ? void 0 : _a.length) === 1; };
|
|
14
|
+
const hasSingleFileUploadSchemaWithCameraOnly = (step) => {
|
|
15
15
|
if (!step.schemas) {
|
|
16
16
|
return false;
|
|
17
17
|
}
|
|
18
|
-
|
|
18
|
+
const schemas = (0, exports.filterHiddenSchemas)(step.schemas);
|
|
19
19
|
if ((schemas === null || schemas === void 0 ? void 0 : schemas.length) !== 1) {
|
|
20
20
|
return false;
|
|
21
21
|
}
|
|
22
|
-
|
|
22
|
+
const firstSchema = schemas[0];
|
|
23
23
|
if (!(0, types_1.isObjectSchema)(firstSchema) || Object.values(firstSchema.properties).length !== 1) {
|
|
24
24
|
return false;
|
|
25
25
|
}
|
|
26
|
-
|
|
26
|
+
const childSchema = Object.values(firstSchema.properties)[0];
|
|
27
27
|
if (!(0, types_1.isFileUploadSchema)(childSchema)) {
|
|
28
28
|
return false;
|
|
29
29
|
}
|
|
30
30
|
return childSchema.source === 'camera';
|
|
31
31
|
};
|
|
32
|
-
|
|
33
|
-
return schemas.filter(
|
|
32
|
+
const filterHiddenSchemas = (schemas) => {
|
|
33
|
+
return schemas.filter((schema) => {
|
|
34
34
|
if ((0, types_1.isObjectSchema)(schema)) {
|
|
35
|
-
return Object.values((schema === null || schema === void 0 ? void 0 : schema.properties) || {}).find(
|
|
35
|
+
return Object.values((schema === null || schema === void 0 ? void 0 : schema.properties) || {}).find((schema) => (schema === null || schema === void 0 ? void 0 : schema.hidden) !== true);
|
|
36
36
|
}
|
|
37
37
|
return (schema === null || schema === void 0 ? void 0 : schema.hidden) !== true;
|
|
38
38
|
});
|
|
39
39
|
};
|
|
40
40
|
exports.filterHiddenSchemas = filterHiddenSchemas;
|
|
41
|
-
|
|
41
|
+
const getStepType = (step) => {
|
|
42
42
|
if (isCameraStep(step)) {
|
|
43
43
|
return exports.stepType.CAMERA;
|
|
44
44
|
}
|
|
@@ -13,16 +13,16 @@ var __createBinding = (this && this.__createBinding) || (Object.create ? (functi
|
|
|
13
13
|
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
14
|
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
15
|
};
|
|
16
|
-
exports
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
17
|
exports.getArrayValidationFailures = exports.getValidationFailures = exports.isValidSchema = exports.getValidBasicModelOrNull = exports.getValidObjectModelParts = exports.getValidModelParts = void 0;
|
|
18
18
|
var model_validators_1 = require("./models/model-validators");
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
19
|
+
Object.defineProperty(exports, "getValidModelParts", { enumerable: true, get: function () { return model_validators_1.getValidModelParts; } });
|
|
20
|
+
Object.defineProperty(exports, "getValidObjectModelParts", { enumerable: true, get: function () { return model_validators_1.getValidObjectModelParts; } });
|
|
21
|
+
Object.defineProperty(exports, "getValidBasicModelOrNull", { enumerable: true, get: function () { return model_validators_1.getValidBasicModelOrNull; } });
|
|
22
22
|
var schema_validators_1 = require("./schemas/schema-validators");
|
|
23
|
-
|
|
23
|
+
Object.defineProperty(exports, "isValidSchema", { enumerable: true, get: function () { return schema_validators_1.isValidSchema; } });
|
|
24
24
|
var validation_failures_1 = require("./validationFailures/validation-failures");
|
|
25
|
-
|
|
26
|
-
|
|
25
|
+
Object.defineProperty(exports, "getValidationFailures", { enumerable: true, get: function () { return validation_failures_1.getValidationFailures; } });
|
|
26
|
+
Object.defineProperty(exports, "getArrayValidationFailures", { enumerable: true, get: function () { return validation_failures_1.getArrayValidationFailures; } });
|
|
27
27
|
__exportStar(require("./types/type-validators"), exports);
|
|
28
28
|
__exportStar(require("./values/value-validators"), exports);
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
exports
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.getValidObjectModelParts = exports.getValidBasicModelOrNull = exports.getValidModelParts = void 0;
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
4
|
+
const types_1 = require("../../../types");
|
|
5
|
+
const types_2 = require("../../../types");
|
|
6
|
+
const validators_1 = require("../../validators");
|
|
7
|
+
const models_utils_1 = require("./models.utils");
|
|
8
|
+
const getValidModelParts = (model, schema) => {
|
|
9
9
|
if ((0, types_1.isObjectModel)(model)) {
|
|
10
10
|
return getValidObjectModelParts(model, schema);
|
|
11
11
|
}
|
|
@@ -22,7 +22,7 @@ function getValidBasicModelOrNull(model, schema) {
|
|
|
22
22
|
if (schema.oneOf) {
|
|
23
23
|
return (0, models_utils_1.cleanBasicModelWithOneOfSchema)(model, schema);
|
|
24
24
|
}
|
|
25
|
-
if (!(0, validators_1.isUndefined)(schema
|
|
25
|
+
if (!(0, validators_1.isUndefined)(schema.const) && model === schema.const) {
|
|
26
26
|
return model;
|
|
27
27
|
}
|
|
28
28
|
if (schema.type) {
|
|
@@ -52,7 +52,7 @@ function getValidObjectModelParts(model, schema) {
|
|
|
52
52
|
if (schema.oneOf) {
|
|
53
53
|
return (0, models_utils_1.cleanObjectModelWithOneOfSchema)(model, schema);
|
|
54
54
|
}
|
|
55
|
-
if (!(0, validators_1.isUndefined)(schema
|
|
55
|
+
if (!(0, validators_1.isUndefined)(schema.const) && model === schema.const) {
|
|
56
56
|
return model;
|
|
57
57
|
}
|
|
58
58
|
return (0, types_1.isObjectSchema)(schema) ? (0, models_utils_1.cleanObjectModelWithObjectSchema)(model, schema) : null;
|
|
@@ -1,36 +1,25 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
|
|
3
|
-
__assign = Object.assign || function(t) {
|
|
4
|
-
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
5
|
-
s = arguments[i];
|
|
6
|
-
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
|
7
|
-
t[p] = s[p];
|
|
8
|
-
}
|
|
9
|
-
return t;
|
|
10
|
-
};
|
|
11
|
-
return __assign.apply(this, arguments);
|
|
12
|
-
};
|
|
13
|
-
exports.__esModule = true;
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
14
3
|
exports.cleanObjectModelWithOneOfSchema = exports.cleanObjectModelWithAllOfSchema = exports.cleanObjectModelWithObjectSchema = exports.cleanModelWithArraySchema = exports.cleanModelWithBooleanSchema = exports.cleanModelWithNumberSchema = exports.cleanModelWithStringSchema = exports.cleanArrayModelWithOneOfSchema = exports.cleanBasicModelWithOneOfSchema = void 0;
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
4
|
+
const types_1 = require("../../../types");
|
|
5
|
+
const type_validators_1 = require("../types/type-validators");
|
|
6
|
+
const value_validators_1 = require("../values/value-validators");
|
|
7
|
+
const model_validators_1 = require("./model-validators");
|
|
19
8
|
function cleanBasicModelWithOneOfSchema(model, schema) {
|
|
20
|
-
return schema.oneOf.some(
|
|
9
|
+
return schema.oneOf.some((nestedSchema) => (0, model_validators_1.getValidBasicModelOrNull)(model, nestedSchema) === model)
|
|
21
10
|
? model
|
|
22
11
|
: null;
|
|
23
12
|
}
|
|
24
13
|
exports.cleanBasicModelWithOneOfSchema = cleanBasicModelWithOneOfSchema;
|
|
25
14
|
function cleanArrayModelWithOneOfSchema(model, schema) {
|
|
26
15
|
var _a;
|
|
27
|
-
|
|
28
|
-
.map(
|
|
29
|
-
.filter(
|
|
16
|
+
const validModels = schema.oneOf
|
|
17
|
+
.map((nestedSchema) => getValidArrayModelOrNull(model, nestedSchema))
|
|
18
|
+
.filter((item) => item !== null);
|
|
30
19
|
if (validModels.length === 0) {
|
|
31
20
|
return null;
|
|
32
21
|
}
|
|
33
|
-
return (_a = validModels.find(
|
|
22
|
+
return (_a = validModels.find((model) => model.some((item) => item !== null))) !== null && _a !== void 0 ? _a : validModels[0];
|
|
34
23
|
}
|
|
35
24
|
exports.cleanArrayModelWithOneOfSchema = cleanArrayModelWithOneOfSchema;
|
|
36
25
|
function getValidArrayModelOrNull(model, schema) {
|
|
@@ -62,24 +51,23 @@ function cleanModelWithArraySchema(model, schema) {
|
|
|
62
51
|
return null; // we don't support tuples at the moment
|
|
63
52
|
}
|
|
64
53
|
if (model.length > 0) {
|
|
65
|
-
|
|
66
|
-
if (!model.every(
|
|
54
|
+
const expectedType = typeof model[0];
|
|
55
|
+
if (!model.every((item) => typeof item === expectedType)) {
|
|
67
56
|
return new Array(model.length).fill(null);
|
|
68
57
|
}
|
|
69
58
|
}
|
|
70
|
-
return model.map(
|
|
59
|
+
return model.map((childModel) => (0, model_validators_1.getValidBasicModelOrNull)(childModel, schema.items));
|
|
71
60
|
}
|
|
72
61
|
exports.cleanModelWithArraySchema = cleanModelWithArraySchema;
|
|
73
62
|
function cleanObjectModelWithObjectSchema(model, schema) {
|
|
74
|
-
return Object.keys(schema.properties).reduce(
|
|
75
|
-
var _a;
|
|
63
|
+
return Object.keys(schema.properties).reduce((cleanedModel, property) => {
|
|
76
64
|
// If the property exists in the model, clean it, and add it
|
|
77
65
|
if (model && !(0, type_validators_1.isUndefined)(model[property])) {
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
66
|
+
const subModel = model[property];
|
|
67
|
+
const subSchema = schema.properties[property];
|
|
68
|
+
const newValue = (0, model_validators_1.getValidModelParts)(subModel, subSchema);
|
|
81
69
|
if (!(0, type_validators_1.isNull)(newValue)) {
|
|
82
|
-
return
|
|
70
|
+
return Object.assign(Object.assign({}, cleanedModel), { [property]: newValue });
|
|
83
71
|
}
|
|
84
72
|
}
|
|
85
73
|
return cleanedModel;
|
|
@@ -87,11 +75,11 @@ function cleanObjectModelWithObjectSchema(model, schema) {
|
|
|
87
75
|
}
|
|
88
76
|
exports.cleanObjectModelWithObjectSchema = cleanObjectModelWithObjectSchema;
|
|
89
77
|
function cleanObjectModelWithAllOfSchema(model, schema) {
|
|
90
|
-
return schema.allOf.reduce(
|
|
91
|
-
|
|
78
|
+
return schema.allOf.reduce((cleanObjectModel, nestedSchema) => {
|
|
79
|
+
const validSubsetOfModel = (0, model_validators_1.getValidObjectModelParts)(model, nestedSchema);
|
|
92
80
|
if ((0, types_1.isObjectModel)(validSubsetOfModel)) {
|
|
93
81
|
// Extend model with valid subset
|
|
94
|
-
return
|
|
82
|
+
return Object.assign(Object.assign({}, cleanObjectModel), validSubsetOfModel);
|
|
95
83
|
}
|
|
96
84
|
return cleanObjectModel;
|
|
97
85
|
}, {});
|
|
@@ -99,8 +87,8 @@ function cleanObjectModelWithAllOfSchema(model, schema) {
|
|
|
99
87
|
exports.cleanObjectModelWithAllOfSchema = cleanObjectModelWithAllOfSchema;
|
|
100
88
|
function cleanObjectModelWithOneOfSchema(model, schema) {
|
|
101
89
|
return schema.oneOf
|
|
102
|
-
.map(
|
|
103
|
-
.reduce(
|
|
90
|
+
.map((nestedSchema) => (0, model_validators_1.getValidObjectModelParts)(model, nestedSchema))
|
|
91
|
+
.reduce((combined, current) => {
|
|
104
92
|
// If we didn't find anything valid yet, and current is good, return it
|
|
105
93
|
if ((0, type_validators_1.isNull)(combined)) {
|
|
106
94
|
return current;
|
|
@@ -118,13 +106,12 @@ function cleanObjectModelWithOneOfSchema(model, schema) {
|
|
|
118
106
|
}
|
|
119
107
|
exports.cleanObjectModelWithOneOfSchema = cleanObjectModelWithOneOfSchema;
|
|
120
108
|
function deepMergeObject(object1, object2) {
|
|
121
|
-
return Object.keys(object2).reduce(
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
var object2Property = object2[property];
|
|
109
|
+
return Object.keys(object2).reduce((acc, property) => {
|
|
110
|
+
const object1Property = object1[property];
|
|
111
|
+
const object2Property = object2[property];
|
|
125
112
|
if ((0, types_1.isObjectModel)(object1Property) && (0, types_1.isObjectModel)(object2Property)) {
|
|
126
|
-
return
|
|
113
|
+
return Object.assign(Object.assign({}, acc), { [property]: deepMergeObject(object1Property, object2Property) });
|
|
127
114
|
}
|
|
128
|
-
return
|
|
129
|
-
},
|
|
115
|
+
return Object.assign(Object.assign({}, acc), { [property]: object2[property] });
|
|
116
|
+
}, Object.assign({}, object1));
|
|
130
117
|
}
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
exports
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.isValidSchema = void 0;
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
4
|
+
const types_1 = require("../../../types");
|
|
5
|
+
const type_validators_1 = require("../types/type-validators");
|
|
6
|
+
const validation_failures_1 = require("../validationFailures/validation-failures");
|
|
7
7
|
function isValidStringSchema(value, schema) {
|
|
8
8
|
return !(0, validation_failures_1.getStringValidationFailures)(value, schema).length;
|
|
9
9
|
}
|
|
@@ -24,10 +24,8 @@ function isValidObjectSchema(value, schema) {
|
|
|
24
24
|
return false;
|
|
25
25
|
}
|
|
26
26
|
return Object.keys(schema.properties)
|
|
27
|
-
.map(
|
|
28
|
-
|
|
29
|
-
})
|
|
30
|
-
.every(function (property) { return property; });
|
|
27
|
+
.map((propertyName) => isObjectPropertyValid(value[propertyName], schema.properties[propertyName], schema.required && schema.required.includes(propertyName)))
|
|
28
|
+
.every((property) => property);
|
|
31
29
|
}
|
|
32
30
|
function isObjectPropertyValid(propertyValue, propertySchema, isRequired) {
|
|
33
31
|
if (typeof propertyValue === 'undefined') {
|
|
@@ -44,21 +42,21 @@ function isValidArraySchema(value, schema) {
|
|
|
44
42
|
}
|
|
45
43
|
return (Array.isArray(value) &&
|
|
46
44
|
(0, types_1.isListArraySchema)(schema) && // TupleArraySchema not yet supported
|
|
47
|
-
value.map(
|
|
45
|
+
value.map((item) => isValidSchema(item, schema.items)).every((valid) => valid));
|
|
48
46
|
}
|
|
49
47
|
function isValidOneOfSchema(value, schema) {
|
|
50
48
|
if (!(0, type_validators_1.isArray)(schema.oneOf)) {
|
|
51
49
|
return false;
|
|
52
50
|
}
|
|
53
|
-
return schema.oneOf.some(
|
|
51
|
+
return schema.oneOf.some((childSchema) => isValidSchema(value, childSchema));
|
|
54
52
|
}
|
|
55
53
|
function isValidAllOfSchema(value, schema) {
|
|
56
54
|
if (!(0, type_validators_1.isArray)(schema.allOf)) {
|
|
57
55
|
return false;
|
|
58
56
|
}
|
|
59
57
|
return schema.allOf
|
|
60
|
-
.map(
|
|
61
|
-
.every(
|
|
58
|
+
.map((childSchema) => isValidSchema(value, childSchema))
|
|
59
|
+
.every((valid) => valid);
|
|
62
60
|
}
|
|
63
61
|
function isValidBlobSchema(value, schema) {
|
|
64
62
|
return !(0, validation_failures_1.getBlobValidationFailures)(value, schema).length;
|
|
@@ -76,7 +74,7 @@ function isValidSchema(value, schema) {
|
|
|
76
74
|
if (schema.allOf) {
|
|
77
75
|
return isValidAllOfSchema(value, schema);
|
|
78
76
|
}
|
|
79
|
-
if (schema
|
|
77
|
+
if (schema.const) {
|
|
80
78
|
return isValidConstSchema(value, schema);
|
|
81
79
|
}
|
|
82
80
|
switch (schema.type) {
|
|
@@ -1,25 +1,21 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
exports
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.isUndefined = exports.isNull = exports.isArray = exports.isObject = exports.isBoolean = exports.isInteger = exports.isNumber = exports.isString = void 0;
|
|
4
|
-
|
|
4
|
+
const isString = (value) => typeof value === 'string';
|
|
5
5
|
exports.isString = isString;
|
|
6
|
-
|
|
7
|
-
return typeof value === 'number' && !Number.isNaN(value);
|
|
8
|
-
};
|
|
6
|
+
const isNumber = (value) => typeof value === 'number' && !Number.isNaN(value);
|
|
9
7
|
exports.isNumber = isNumber;
|
|
10
|
-
|
|
8
|
+
const isInteger = (value) => {
|
|
11
9
|
return (0, exports.isNumber)(value) && Math.floor(value) === value;
|
|
12
10
|
};
|
|
13
11
|
exports.isInteger = isInteger;
|
|
14
|
-
|
|
12
|
+
const isBoolean = (value) => typeof value === 'boolean';
|
|
15
13
|
exports.isBoolean = isBoolean;
|
|
16
|
-
|
|
17
|
-
return !(0, exports.isNull)(value) && !(0, exports.isUndefined)(value) && (value === null || value === void 0 ? void 0 : value.constructor) === Object;
|
|
18
|
-
};
|
|
14
|
+
const isObject = (value) => !(0, exports.isNull)(value) && !(0, exports.isUndefined)(value) && (value === null || value === void 0 ? void 0 : value.constructor) === Object;
|
|
19
15
|
exports.isObject = isObject;
|
|
20
|
-
|
|
16
|
+
const isArray = (value) => Array.isArray(value);
|
|
21
17
|
exports.isArray = isArray;
|
|
22
|
-
|
|
18
|
+
const isNull = (value) => value === null;
|
|
23
19
|
exports.isNull = isNull;
|
|
24
|
-
|
|
20
|
+
const isUndefined = (value) => typeof value === 'undefined';
|
|
25
21
|
exports.isUndefined = isUndefined;
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
exports
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.getBlobValidationFailures = exports.getObjectValidationFailures = exports.getArrayValidationFailures = exports.getConstValidationFailures = exports.getBooleanValidationFailures = exports.getIntegerValidationFailures = exports.getNumberValidationFailures = exports.getStringValidationFailures = exports.getValidationFailures = void 0;
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
4
|
+
const types_1 = require("../../../types");
|
|
5
|
+
const Schema_1 = require("../../../types/specification/Schema");
|
|
6
|
+
const type_validators_1 = require("../types/type-validators");
|
|
7
|
+
const validation_failures_utils_1 = require("./validation-failures.utils");
|
|
8
8
|
function getValidationFailures(value, schema, isRequired) {
|
|
9
|
-
if (schema
|
|
9
|
+
if (schema.const) {
|
|
10
10
|
return getConstValidationFailures(value, schema, isRequired);
|
|
11
11
|
}
|
|
12
12
|
if ((0, type_validators_1.isNull)(value)) {
|
|
@@ -38,7 +38,7 @@ function getStringValidationFailures(value, schema, isRequired) {
|
|
|
38
38
|
if (value === '' && isRequired) {
|
|
39
39
|
return ['required'];
|
|
40
40
|
}
|
|
41
|
-
|
|
41
|
+
const failures = [];
|
|
42
42
|
if (!(0, validation_failures_utils_1.isValidRequired)(value, isRequired)) {
|
|
43
43
|
failures.push('required');
|
|
44
44
|
}
|
|
@@ -64,7 +64,7 @@ function getNumberValidationFailures(value, schema, isRequired) {
|
|
|
64
64
|
if (!(0, type_validators_1.isNumber)(value) && !(0, type_validators_1.isNull)(value)) {
|
|
65
65
|
return ['type'];
|
|
66
66
|
}
|
|
67
|
-
|
|
67
|
+
const failures = [];
|
|
68
68
|
if (!(0, validation_failures_utils_1.isValidRequired)(value, isRequired)) {
|
|
69
69
|
failures.push('required');
|
|
70
70
|
}
|
|
@@ -88,7 +88,7 @@ function getBooleanValidationFailures(value, _schema, isRequired) {
|
|
|
88
88
|
if (!(0, type_validators_1.isBoolean)(value) && !(0, type_validators_1.isNull)(value)) {
|
|
89
89
|
return ['type'];
|
|
90
90
|
}
|
|
91
|
-
|
|
91
|
+
const failures = [];
|
|
92
92
|
if (!(0, validation_failures_utils_1.isValidRequired)(value, isRequired)) {
|
|
93
93
|
failures.push('required');
|
|
94
94
|
}
|
|
@@ -99,7 +99,7 @@ function getConstValidationFailures(value, schema, isRequired) {
|
|
|
99
99
|
if (!(0, validation_failures_utils_1.isValidRequired)(value, isRequired)) {
|
|
100
100
|
return ['required'];
|
|
101
101
|
}
|
|
102
|
-
if (value !== schema
|
|
102
|
+
if (value !== schema.const) {
|
|
103
103
|
return ['const'];
|
|
104
104
|
}
|
|
105
105
|
return [];
|
|
@@ -112,7 +112,7 @@ function getArrayValidationFailures(value, schema, isRequired) {
|
|
|
112
112
|
if (!(0, validation_failures_utils_1.isValidRequiredArray)(value, isRequired)) {
|
|
113
113
|
return ['required'];
|
|
114
114
|
}
|
|
115
|
-
|
|
115
|
+
const failures = [];
|
|
116
116
|
if (!(0, validation_failures_utils_1.isValidMinItems)(value, schema.minItems)) {
|
|
117
117
|
failures.push('minItems');
|
|
118
118
|
}
|
|
@@ -143,9 +143,9 @@ function getObjectValidationFailures(value, schema) {
|
|
|
143
143
|
if (!(0, type_validators_1.isArray)(schema.required)) {
|
|
144
144
|
return [];
|
|
145
145
|
}
|
|
146
|
-
|
|
147
|
-
.map(
|
|
148
|
-
.reduce(
|
|
146
|
+
const allPresent = schema.required
|
|
147
|
+
.map((property) => typeof value[property] !== 'undefined')
|
|
148
|
+
.reduce((propertyInModel, validSoFar) => propertyInModel && validSoFar, true);
|
|
149
149
|
return allPresent ? [] : ['required'];
|
|
150
150
|
}
|
|
151
151
|
exports.getObjectValidationFailures = getObjectValidationFailures;
|
|
@@ -1,14 +1,12 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
exports
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.isValidRequiredArray = exports.isValidMaxItems = exports.isValidMinItems = exports.isValidMinimum = exports.isValidMaximum = exports.isValidPattern = exports.isValidMaxLength = exports.isValidMinLength = exports.isValidRequired = void 0;
|
|
4
|
-
|
|
5
|
-
function isValidRequired(value, isRequired) {
|
|
6
|
-
if (isRequired === void 0) { isRequired = false; }
|
|
4
|
+
const validators_1 = require("../../validators");
|
|
5
|
+
function isValidRequired(value, isRequired = false) {
|
|
7
6
|
return !isRequired || !(0, validators_1.isUndefined)(value);
|
|
8
7
|
}
|
|
9
8
|
exports.isValidRequired = isValidRequired;
|
|
10
|
-
function isValidRequiredArray(value, isRequired) {
|
|
11
|
-
if (isRequired === void 0) { isRequired = false; }
|
|
9
|
+
function isValidRequiredArray(value, isRequired = false) {
|
|
12
10
|
return !isRequired || (0, validators_1.isArray)(value);
|
|
13
11
|
}
|
|
14
12
|
exports.isValidRequiredArray = isValidRequiredArray;
|
|
@@ -27,7 +25,7 @@ function isValidPattern(value, pattern) {
|
|
|
27
25
|
if (value === undefined || value === null) {
|
|
28
26
|
return false; // no value, but there's a pattern, therefore the value is NOT valid
|
|
29
27
|
}
|
|
30
|
-
|
|
28
|
+
const regex = new RegExp(pattern);
|
|
31
29
|
return !!regex.test(value);
|
|
32
30
|
}
|
|
33
31
|
exports.isValidPattern = isValidPattern;
|
|
@@ -1,9 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
exports
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.isEmpty = void 0;
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
(((0, type_validators_1.isObject)(value) || (0, type_validators_1.isArray)(value)) && Object.keys(value).length === 0);
|
|
8
|
-
};
|
|
4
|
+
const type_validators_1 = require("../types/type-validators");
|
|
5
|
+
const isEmpty = (value) => ((0, type_validators_1.isString)(value) && value.length === 0) ||
|
|
6
|
+
(((0, type_validators_1.isObject)(value) || (0, type_validators_1.isArray)(value)) && Object.keys(value).length === 0);
|
|
9
7
|
exports.isEmpty = isEmpty;
|