@zohodesk/library-platform 1.1.9-exp.1 → 1.1.10
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/es/bc/field-validation/Constants.js +4 -0
- package/es/bc/field-validation/EventHandlers.js +1 -0
- package/es/bc/field-validation/Events.js +106 -0
- package/es/bc/field-validation/FieldTypes.js +20 -0
- package/es/bc/field-validation/Properties.js +11 -0
- package/es/bc/field-validation/index.js +5 -0
- package/es/cc/ephi-tag/Properties.js +1 -0
- package/es/cc/ephi-tag/index.js +1 -0
- package/es/cc/info-icon/Properties.js +10 -0
- package/es/cc/info-icon/index.js +1 -0
- package/es/{platform/app-context-behaviour → library/behaviours/field-validation}/adapters/controllers/AbstractController.js +4 -2
- package/es/library/behaviours/field-validation/adapters/controllers/ValidateFieldController.js +32 -0
- package/es/library/behaviours/field-validation/adapters/controllers/ValidateFieldsController.js +31 -0
- package/es/library/behaviours/field-validation/adapters/gateway/Repository.js +23 -0
- package/es/library/behaviours/field-validation/adapters/gateway/Service.js +18 -0
- package/es/library/behaviours/field-validation/applications/interfaces/input/FieldData.js +17 -0
- package/es/library/behaviours/field-validation/applications/usecases/AbstractUseCase.js +15 -0
- package/es/library/behaviours/field-validation/applications/usecases/ValidateField.js +29 -0
- package/es/library/behaviours/field-validation/applications/usecases/ValidateFields.js +28 -0
- package/es/library/behaviours/field-validation/domain/FieldValidation.js +94 -0
- package/es/library/behaviours/field-validation/domain/field-vise-validations/BooleanValidation.js +28 -0
- package/es/library/behaviours/field-validation/domain/field-vise-validations/CurrencyValidation.js +49 -0
- package/es/library/behaviours/field-validation/domain/field-vise-validations/DateTimeValidation.js +24 -0
- package/es/library/behaviours/field-validation/domain/field-vise-validations/DateValidation.js +24 -0
- package/es/library/behaviours/field-validation/domain/field-vise-validations/DecimalValidation.js +49 -0
- package/es/library/behaviours/field-validation/domain/field-vise-validations/EmailValidation.js +28 -0
- package/es/library/behaviours/field-validation/domain/field-vise-validations/IntegerValidation.js +39 -0
- package/es/library/behaviours/field-validation/domain/field-vise-validations/LookUpValidation.js +24 -0
- package/es/library/behaviours/field-validation/domain/field-vise-validations/MultiSelectValidation.js +26 -0
- package/es/library/behaviours/field-validation/domain/field-vise-validations/PercentValidation.js +28 -0
- package/es/library/behaviours/field-validation/domain/field-vise-validations/PhoneValidation.js +39 -0
- package/es/library/behaviours/field-validation/domain/field-vise-validations/PicklistValidation.js +24 -0
- package/es/library/behaviours/field-validation/domain/field-vise-validations/TextAreaValidation.js +39 -0
- package/es/library/behaviours/field-validation/domain/field-vise-validations/TextBoxValidation.js +39 -0
- package/es/library/behaviours/field-validation/domain/field-vise-validations/URLValidation.js +28 -0
- package/es/library/behaviours/field-validation/domain/interfaces/FieldTypes.js +20 -0
- package/es/library/behaviours/field-validation/domain/interfaces/ValidationsEnum.js +22 -0
- package/es/library/behaviours/field-validation/domain/interfaces/ValidationsMap.js +1 -0
- package/es/library/behaviours/field-validation/domain/interfaces/fields/IDateField.js +0 -0
- package/es/library/behaviours/field-validation/domain/interfaces/fields/IDateTimeField.js +0 -0
- package/es/library/behaviours/field-validation/domain/interfaces/fields/IDecimalField.js +0 -0
- package/es/library/behaviours/field-validation/domain/interfaces/fields/IEmailField.js +0 -0
- package/es/library/behaviours/field-validation/domain/interfaces/fields/IIntegerField.js +0 -0
- package/es/library/behaviours/field-validation/domain/interfaces/fields/ILookUpField.js +0 -0
- package/es/library/behaviours/field-validation/domain/interfaces/fields/IMultiSelectField.js +0 -0
- package/es/library/behaviours/field-validation/domain/interfaces/fields/IPercentField.js +0 -0
- package/es/library/behaviours/field-validation/domain/interfaces/fields/IPhoneField.js +0 -0
- package/es/library/behaviours/field-validation/domain/interfaces/fields/IPicklistField.js +0 -0
- package/es/library/behaviours/field-validation/domain/interfaces/fields/ITextAreaField.js +0 -0
- package/es/library/behaviours/field-validation/domain/interfaces/fields/ITextBoxField.js +0 -0
- package/es/library/behaviours/field-validation/domain/interfaces/fields/IURLField.js +0 -0
- package/es/library/behaviours/field-validation/frameworks/ui/EventHandlerFactory.js +23 -0
- package/es/library/behaviours/field-validation/frameworks/ui/FieldValidationBehaviourFactory.js +27 -0
- package/es/library/behaviours/field-validation/frameworks/ui/__tests__/BooleanFieldValidation.test.js +137 -0
- package/es/library/behaviours/field-validation/frameworks/ui/__tests__/CurrencyFieldValidation.test.js +228 -0
- package/es/library/behaviours/field-validation/frameworks/ui/__tests__/DateFieldValidation.test.js +108 -0
- package/es/library/behaviours/field-validation/frameworks/ui/__tests__/DateTimeFieldValidation.test.js +108 -0
- package/es/library/behaviours/field-validation/frameworks/ui/__tests__/DecimalFieldValidation.test.js +257 -0
- package/es/library/behaviours/field-validation/frameworks/ui/__tests__/EmailFieldValidation.test.js +139 -0
- package/es/library/behaviours/field-validation/frameworks/ui/__tests__/FieldValidationBehaviour.test.js +171 -0
- package/es/library/behaviours/field-validation/frameworks/ui/__tests__/IntegerFieldValidation.test.js +168 -0
- package/es/library/behaviours/field-validation/frameworks/ui/__tests__/LookUpFieldValidation.test.js +108 -0
- package/es/library/behaviours/field-validation/frameworks/ui/__tests__/MultiSelectFieldValidation.test.js +79 -0
- package/es/library/behaviours/field-validation/frameworks/ui/__tests__/PercentFieldValidation.test.js +108 -0
- package/es/library/behaviours/field-validation/frameworks/ui/__tests__/PhoneFieldValidation.test.js +168 -0
- package/es/library/behaviours/field-validation/frameworks/ui/__tests__/PicklistFieldValidation.test.js +79 -0
- package/es/library/behaviours/field-validation/frameworks/ui/__tests__/TextAreaFieldValidation.test.js +170 -0
- package/es/library/behaviours/field-validation/frameworks/ui/__tests__/TextBoxFieldValidation.test.js +170 -0
- package/es/library/behaviours/field-validation/frameworks/ui/__tests__/URLFieldValidation.test.js +108 -0
- package/es/library/behaviours/field-validation/frameworks/utils/FormBasicValidationAdaptor.js +228 -0
- package/es/library/behaviours/field-validation/frameworks/utils/__tests__/formValidate.test.js +284 -0
- package/es/library/behaviours/field-validation/frameworks/utils/formValidate.js +334 -0
- package/es/library/dot/components/form-fields/checkbox/adapters/presenter/TransformState.js +22 -0
- package/es/library/dot/components/form-fields/currency/adapters/presenter/TransformState.js +81 -0
- package/es/library/dot/components/form-fields/date/adapters/presenter/TransformState.js +22 -0
- package/es/library/dot/components/form-fields/datetime/adapters/presenter/TransformState.js +22 -0
- package/es/library/dot/components/form-fields/decimal/adapters/presenter/TransformState.js +31 -0
- package/es/library/dot/components/form-fields/email/adapters/presenter/TransformState.js +23 -0
- package/es/library/dot/components/form-fields/ephi-tag/frameworks/ui/EPHITag.js +10 -0
- package/es/library/dot/components/form-fields/ephi-tag/frameworks/ui/EPHITagView.js +21 -0
- package/es/library/dot/components/form-fields/ephi-tag/frameworks/ui/css/EPHITag.module.css +3 -0
- package/es/library/dot/components/form-fields/info-icon/frameworks/ui/InfoIcon.js +10 -0
- package/es/library/dot/components/form-fields/info-icon/frameworks/ui/InfoIconView.js +21 -0
- package/es/library/dot/components/form-fields/info-icon/frameworks/ui/css/InfoIcon.module.css +3 -0
- package/es/library/dot/components/form-fields/multi-select/adapters/presenter/TransformState.js +31 -0
- package/es/library/dot/components/form-fields/number/adapters/presenter/TransformState.js +31 -0
- package/es/library/dot/components/form-fields/percentage/adapters/presenter/TransformState.js +31 -0
- package/es/library/dot/components/form-fields/phone/adapters/presenter/TransformState.js +31 -0
- package/es/library/dot/components/form-fields/pick-list/adapters/presenter/TransformState.js +23 -0
- package/es/library/dot/components/form-fields/textarea/adapters/presenter/TransformState.js +23 -0
- package/es/library/dot/components/form-fields/textbox/adapters/presenter/TransformState.js +32 -0
- package/es/library/dot/components/form-fields/url/adapters/presenter/TransformState.js +31 -0
- package/es/library/dot/components/section/adapters/presenter/TransFormState.js +26 -0
- package/es/library/dot/legacy-to-new-arch/label/frameworks/ui/sub-components/ui/LabelAction.js +9 -0
- package/es/library/dot/legacy-to-new-arch/label/frameworks/ui/sub-components/ui/LabelActionView.js +38 -0
- package/es/library/dot/legacy-to-new-arch/label/frameworks/ui/sub-components/ui/css/LabelAction.module.css +4 -0
- package/es/platform/components/form-connected/adapters/resources/SmartFormResources.js +18 -0
- package/es/platform/components/form-connected/frameworks/FormSdkFactory.js +4 -2
- package/es/platform/zdata-source/domain/entities/APITemplate.js +2 -1
- package/es/platform/zform/adapters/controllers/ValidateErrorMessageController.js +22 -0
- package/es/platform/zform/applications/interfaces/input/GetIsFieldValueChangedUseCaseInput.js +1 -0
- package/es/platform/zform/applications/interfaces/input/ValidateErrorMessageInputModel.js +1 -0
- package/es/platform/zform/applications/usecases/GetIsFieldValueChanged.js +35 -0
- package/es/platform/zform/applications/usecases/ValidateErrorMessageUseCase.js +33 -0
- package/es/platform/zform/applications/usecases/ValidateFieldRequestUseCase.js +56 -0
- package/es/platform/zform/domain/ZField.js +4 -0
- package/package.json +1 -1
- package/es/bc/app-context/Event.js +0 -1
- package/es/bc/app-context/Properties.js +0 -58
- package/es/cc/component/ErrorStructure.js +0 -9
- package/es/cc/error-state/ErrorTypes.js +0 -11
- package/es/cc/error-state/Properties.js +0 -31
- package/es/cc/error-state/index.js +0 -2
- package/es/library/custom-component/domain/entities/ComponentProperties.js +0 -121
- package/es/library/custom-component/domain/entities/Logger.js +0 -63
- package/es/library/dot/legacy-to-new-arch/error-state/frameworks/ui/ErrorState.js +0 -10
- package/es/library/dot/legacy-to-new-arch/error-state/frameworks/ui/ErrorStateView.js +0 -68
- package/es/platform/app-context-behaviour/adapters/controllers/InitializeController.js +0 -19
- package/es/platform/app-context-behaviour/adapters/gateways/Service.js +0 -7
- package/es/platform/app-context-behaviour/adapters/presenters/Presenter.js +0 -18
- package/es/platform/app-context-behaviour/adapters/resources/AppResource.js +0 -25
- package/es/platform/app-context-behaviour/applications/AbstractUseCase.js +0 -6
- package/es/platform/app-context-behaviour/applications/usecases/InitializeUseCase.js +0 -15
- package/es/platform/app-context-behaviour/frameworks/AppContextBehaviourFactory.js +0 -31
- package/es/platform/app-context-behaviour/frameworks/EventHandlerFactory.js +0 -25
- package/es/platform/components/form-connected/frameworks/FallbackView.js +0 -23
- package/es/platform/data-source/http-template/getDependencyMappings.js +0 -18
- package/es/platform/data-source/http-template/getLayoutRules.js +0 -29
- package/es/platform/data-source/http-template/getMyForm.js +0 -19
- package/es/platform/data-source/http-template/getMyLayout.js +0 -43
- package/es/platform/data-source/http-template/getValidationRules.js +0 -30
- package/es/platform/zform/adapters/controllers/ApiFailureController.js +0 -31
- package/es/platform/zform/applications/usecases/ApiFailureUseCase.js +0 -30
- /package/es/{platform/app-context-behaviour/applications/interfaces/UsecaseDependencies.js → library/behaviours/field-validation/applications/interfaces/UseCaseDependencies.js} +0 -0
- /package/es/{platform/app-context-behaviour/applications/interfaces/gateways/IService.js → library/behaviours/field-validation/applications/interfaces/gateways/IRepository.js} +0 -0
- /package/es/{platform/app-context-behaviour/applications/interfaces/input/InitializeUseCaseInputModel.js → library/behaviours/field-validation/applications/interfaces/gateways/IService.js} +0 -0
- /package/es/{platform/app-context-behaviour/applications/interfaces/output/BehaviourState.js → library/behaviours/field-validation/applications/interfaces/input/FieldValidationInputModel.js} +0 -0
- /package/es/{platform/app-context-behaviour/applications/interfaces/output/IPresenter.js → library/behaviours/field-validation/applications/interfaces/input/ValidateFieldsInputModel.js} +0 -0
- /package/es/{bc/app-context/Constants.js → library/behaviours/field-validation/domain/interfaces/IField.js} +0 -0
- /package/es/{platform/app-context-behaviour/applications/interfaces/resources/ApiHeaderContract.js → library/behaviours/field-validation/domain/interfaces/IFieldValidation.js} +0 -0
- /package/es/{platform/app-context-behaviour/applications/interfaces/resources/ContextContract.js → library/behaviours/field-validation/domain/interfaces/IFieldViseValidation.js} +0 -0
- /package/es/{platform/app-context-behaviour/applications/interfaces/resources/IAppResource.js → library/behaviours/field-validation/domain/interfaces/ValidationResult.js} +0 -0
- /package/es/{platform/zform/applications/interfaces/input/ApiFailureInputModel.js → library/behaviours/field-validation/domain/interfaces/ValidationsArray.js} +0 -0
- /package/es/{bc/app-context/EventHandlers.js → library/behaviours/field-validation/domain/interfaces/fields/IBooleanField.js} +0 -0
- /package/es/library/{custom-component/domain/entities/interfaces/IComponentProperties.js → behaviours/field-validation/domain/interfaces/fields/ICurrencyField.js} +0 -0
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
export const VALIDATE_FIELD = 'FIELD_VALIDATION#VALIDATE_FIELD';
|
|
2
|
+
export const FIELD_VALIDATION_RESULT = 'FIELD_VALIDATION#FIELD_VALIDATION_RESULT';
|
|
3
|
+
export const VALIDATE_FIELDS = 'FIELD_VALIDATION#VALIDATE_FIELDS';
|
|
4
|
+
export const VALIDATE_FIELDS_RESULT = 'FIELD_VALIDATION#VALIDATE_FIELDS_RESULT';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import { VALIDATE_FIELD } from "./Constants";
|
|
@@ -0,0 +1,106 @@
|
|
|
1
|
+
import { VALIDATE_FIELD, FIELD_VALIDATION_RESULT, VALIDATE_FIELDS, VALIDATE_FIELDS_RESULT } from "./Constants";
|
|
2
|
+
const fieldMeta = {
|
|
3
|
+
type: 'object',
|
|
4
|
+
properties: {
|
|
5
|
+
name: {
|
|
6
|
+
type: 'string'
|
|
7
|
+
},
|
|
8
|
+
type: {
|
|
9
|
+
type: 'string'
|
|
10
|
+
},
|
|
11
|
+
value: {
|
|
12
|
+
type: 'any'
|
|
13
|
+
}
|
|
14
|
+
}
|
|
15
|
+
};
|
|
16
|
+
const Events = [{
|
|
17
|
+
type: VALIDATE_FIELD,
|
|
18
|
+
payload: {
|
|
19
|
+
fields: {
|
|
20
|
+
required: true,
|
|
21
|
+
typeMetadata: {
|
|
22
|
+
schema: {
|
|
23
|
+
type: 'array',
|
|
24
|
+
items: fieldMeta
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
}, {
|
|
30
|
+
type: FIELD_VALIDATION_RESULT,
|
|
31
|
+
payload: {
|
|
32
|
+
validationResult: {
|
|
33
|
+
required: true,
|
|
34
|
+
typeMetadata: {
|
|
35
|
+
schema: {
|
|
36
|
+
type: 'object',
|
|
37
|
+
properties: {
|
|
38
|
+
isValid: {
|
|
39
|
+
type: 'boolean'
|
|
40
|
+
},
|
|
41
|
+
message: {
|
|
42
|
+
type: 'string'
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
},
|
|
48
|
+
field: {
|
|
49
|
+
required: true,
|
|
50
|
+
typeMetadata: {
|
|
51
|
+
schema: fieldMeta
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
}, {
|
|
56
|
+
type: VALIDATE_FIELDS,
|
|
57
|
+
payload: {
|
|
58
|
+
fields: {
|
|
59
|
+
required: true,
|
|
60
|
+
typeMetadata: {
|
|
61
|
+
schema: fieldMeta
|
|
62
|
+
}
|
|
63
|
+
},
|
|
64
|
+
value: {
|
|
65
|
+
required: true,
|
|
66
|
+
typeMetadata: {
|
|
67
|
+
schema: {
|
|
68
|
+
type: 'any'
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
}, {
|
|
74
|
+
type: VALIDATE_FIELDS_RESULT,
|
|
75
|
+
payload: {
|
|
76
|
+
validationResults: {
|
|
77
|
+
required: true,
|
|
78
|
+
typeMetadata: {
|
|
79
|
+
schema: {
|
|
80
|
+
type: 'Array',
|
|
81
|
+
items: {
|
|
82
|
+
type: 'object',
|
|
83
|
+
properties: {
|
|
84
|
+
isValid: {
|
|
85
|
+
type: 'boolean'
|
|
86
|
+
},
|
|
87
|
+
message: {
|
|
88
|
+
type: 'string'
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
},
|
|
95
|
+
fields: {
|
|
96
|
+
required: true,
|
|
97
|
+
typeMetadata: {
|
|
98
|
+
schema: {
|
|
99
|
+
type: 'array',
|
|
100
|
+
items: fieldMeta
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
}];
|
|
106
|
+
export default Events;
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
var FieldTypes = /*#__PURE__*/function (FieldTypes) {
|
|
2
|
+
FieldTypes["TextBox"] = "Text";
|
|
3
|
+
FieldTypes["Email"] = "Email";
|
|
4
|
+
FieldTypes["Decimal"] = "Decimal";
|
|
5
|
+
FieldTypes["Integer"] = "Integer";
|
|
6
|
+
FieldTypes["Phone"] = "Phone";
|
|
7
|
+
FieldTypes["Date"] = "Date";
|
|
8
|
+
FieldTypes["DateTime"] = "DateTime";
|
|
9
|
+
FieldTypes["Boolean"] = "Boolean";
|
|
10
|
+
FieldTypes["MultiSelect"] = "MultiSelect";
|
|
11
|
+
FieldTypes["Picklist"] = "Picklist";
|
|
12
|
+
FieldTypes["Percent"] = "Percent";
|
|
13
|
+
FieldTypes["Currency"] = "Currency";
|
|
14
|
+
FieldTypes["URL"] = "URL";
|
|
15
|
+
FieldTypes["LookUp"] = "LookUp";
|
|
16
|
+
FieldTypes["TextArea"] = "TextArea";
|
|
17
|
+
return FieldTypes;
|
|
18
|
+
}(FieldTypes || {});
|
|
19
|
+
|
|
20
|
+
export default FieldTypes;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export default {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { default as EPHITagProperties } from "./Properties";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { default as InfoIconProperties } from "./Properties";
|
package/es/library/behaviours/field-validation/adapters/controllers/ValidateFieldController.js
ADDED
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import AbstractController from "./AbstractController";
|
|
2
|
+
|
|
3
|
+
class ValidateFieldController extends AbstractController {
|
|
4
|
+
handle(event) {
|
|
5
|
+
const {
|
|
6
|
+
validateFieldUseCase
|
|
7
|
+
} = this.service;
|
|
8
|
+
const {
|
|
9
|
+
state,
|
|
10
|
+
updateState,
|
|
11
|
+
action,
|
|
12
|
+
dispatch
|
|
13
|
+
} = event;
|
|
14
|
+
const {
|
|
15
|
+
field,
|
|
16
|
+
value
|
|
17
|
+
} = action.payload;
|
|
18
|
+
const {
|
|
19
|
+
metadata
|
|
20
|
+
} = action;
|
|
21
|
+
validateFieldUseCase.updateDependencies(state, updateState);
|
|
22
|
+
validateFieldUseCase.execute({
|
|
23
|
+
field,
|
|
24
|
+
value,
|
|
25
|
+
dispatch,
|
|
26
|
+
metadata
|
|
27
|
+
});
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
export default ValidateFieldController;
|
package/es/library/behaviours/field-validation/adapters/controllers/ValidateFieldsController.js
ADDED
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import AbstractController from "./AbstractController";
|
|
2
|
+
|
|
3
|
+
class ValidateFieldsController extends AbstractController {
|
|
4
|
+
handle(event) {
|
|
5
|
+
const {
|
|
6
|
+
validateFieldsUseCase
|
|
7
|
+
} = this.service;
|
|
8
|
+
const {
|
|
9
|
+
state,
|
|
10
|
+
updateState,
|
|
11
|
+
action,
|
|
12
|
+
dispatch
|
|
13
|
+
} = event;
|
|
14
|
+
const {
|
|
15
|
+
fields,
|
|
16
|
+
value
|
|
17
|
+
} = action.payload;
|
|
18
|
+
const {
|
|
19
|
+
metadata
|
|
20
|
+
} = action;
|
|
21
|
+
validateFieldsUseCase.updateDependencies(state, updateState);
|
|
22
|
+
validateFieldsUseCase.execute({
|
|
23
|
+
fields,
|
|
24
|
+
dispatch,
|
|
25
|
+
metadata
|
|
26
|
+
});
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
export default ValidateFieldsController;
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
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; }
|
|
2
|
+
|
|
3
|
+
import FieldValidation from "../../domain/FieldValidation";
|
|
4
|
+
export default class Repository {
|
|
5
|
+
constructor() {
|
|
6
|
+
_defineProperty(this, "state", void 0);
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
init(state) {
|
|
10
|
+
this.state = state;
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
getFieldValidationEntity() {
|
|
14
|
+
const {
|
|
15
|
+
properties
|
|
16
|
+
} = this.state;
|
|
17
|
+
const {
|
|
18
|
+
validations: validationsMap
|
|
19
|
+
} = properties;
|
|
20
|
+
return new FieldValidation(validationsMap);
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
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; }
|
|
2
|
+
|
|
3
|
+
import ValidateField from "../../applications/usecases/ValidateField";
|
|
4
|
+
import ValidateFields from "../../applications/usecases/ValidateFields";
|
|
5
|
+
|
|
6
|
+
class Service {
|
|
7
|
+
constructor(dependencies) {
|
|
8
|
+
_defineProperty(this, "validateFieldUseCase", void 0);
|
|
9
|
+
|
|
10
|
+
_defineProperty(this, "validateFieldsUseCase", void 0);
|
|
11
|
+
|
|
12
|
+
this.validateFieldUseCase = new ValidateField(dependencies);
|
|
13
|
+
this.validateFieldsUseCase = new ValidateFields(dependencies);
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
export default Service;
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
var FieldTypes = /*#__PURE__*/function (FieldTypes) {
|
|
2
|
+
FieldTypes["TextBox"] = "Text";
|
|
3
|
+
FieldTypes["Email"] = "Email";
|
|
4
|
+
FieldTypes["Decimal"] = "Decimal";
|
|
5
|
+
FieldTypes["Integer"] = "Integer";
|
|
6
|
+
FieldTypes["Phone"] = "Phone";
|
|
7
|
+
FieldTypes["Date"] = "Date";
|
|
8
|
+
FieldTypes["DateTime"] = "DateTime";
|
|
9
|
+
FieldTypes["Boolean"] = "Boolean";
|
|
10
|
+
FieldTypes["MultiSelect"] = "MultiSelect";
|
|
11
|
+
FieldTypes["Picklist"] = "Picklist";
|
|
12
|
+
FieldTypes["Percent"] = "Percent";
|
|
13
|
+
FieldTypes["Currency"] = "Currency";
|
|
14
|
+
FieldTypes["URL"] = "URL";
|
|
15
|
+
FieldTypes["TextArea"] = "TextArea";
|
|
16
|
+
return FieldTypes;
|
|
17
|
+
}(FieldTypes || {});
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
class AbstractUseCase {
|
|
2
|
+
constructor(dependencies) {
|
|
3
|
+
this.dependencies = dependencies;
|
|
4
|
+
}
|
|
5
|
+
|
|
6
|
+
updateDependencies(state, updateState) {
|
|
7
|
+
const {
|
|
8
|
+
repository
|
|
9
|
+
} = this.dependencies;
|
|
10
|
+
repository.init(state);
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
export default AbstractUseCase;
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { FIELD_VALIDATION_RESULT } from "../../../../../bc/field-validation/Constants";
|
|
2
|
+
import AbstractUseCase from "./AbstractUseCase";
|
|
3
|
+
|
|
4
|
+
class ValidateField extends AbstractUseCase {
|
|
5
|
+
execute(input) {
|
|
6
|
+
const {
|
|
7
|
+
field,
|
|
8
|
+
value,
|
|
9
|
+
dispatch,
|
|
10
|
+
metadata
|
|
11
|
+
} = input;
|
|
12
|
+
const {
|
|
13
|
+
repository
|
|
14
|
+
} = this.dependencies;
|
|
15
|
+
const fieldValidation = repository.getFieldValidationEntity();
|
|
16
|
+
const validationResult = fieldValidation.validateField(field, value);
|
|
17
|
+
dispatch({
|
|
18
|
+
type: FIELD_VALIDATION_RESULT,
|
|
19
|
+
payload: {
|
|
20
|
+
validationResult,
|
|
21
|
+
field
|
|
22
|
+
},
|
|
23
|
+
metadata
|
|
24
|
+
});
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
export default ValidateField;
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { VALIDATE_FIELDS_RESULT } from "../../../../../bc/field-validation/Constants";
|
|
2
|
+
import AbstractUseCase from "./AbstractUseCase";
|
|
3
|
+
|
|
4
|
+
class ValidateFields extends AbstractUseCase {
|
|
5
|
+
execute(input) {
|
|
6
|
+
const {
|
|
7
|
+
fields,
|
|
8
|
+
dispatch,
|
|
9
|
+
metadata
|
|
10
|
+
} = input;
|
|
11
|
+
const {
|
|
12
|
+
repository
|
|
13
|
+
} = this.dependencies;
|
|
14
|
+
const fieldValidation = repository.getFieldValidationEntity();
|
|
15
|
+
const validationResults = fieldValidation.validateFields(fields);
|
|
16
|
+
dispatch({
|
|
17
|
+
type: VALIDATE_FIELDS_RESULT,
|
|
18
|
+
payload: {
|
|
19
|
+
validationResults,
|
|
20
|
+
fields
|
|
21
|
+
},
|
|
22
|
+
metadata
|
|
23
|
+
});
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
export default ValidateFields;
|
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
import FieldTypes from "./interfaces/FieldTypes";
|
|
2
|
+
import TextBoxValidation from "./field-vise-validations/TextBoxValidation";
|
|
3
|
+
import TextAreaValidation from "./field-vise-validations/TextAreaValidation";
|
|
4
|
+
import EmailValidation from "./field-vise-validations/EmailValidation";
|
|
5
|
+
import CurrencyValidation from "./field-vise-validations/CurrencyValidation";
|
|
6
|
+
import DecimalValidation from "./field-vise-validations/DecimalValidation";
|
|
7
|
+
import BooleanValidation from "./field-vise-validations/BooleanValidation";
|
|
8
|
+
import DateTimeValidation from "./field-vise-validations/DateTimeValidation";
|
|
9
|
+
import DateValidation from "./field-vise-validations/DateValidation";
|
|
10
|
+
import IntegerValidation from "./field-vise-validations/IntegerValidation";
|
|
11
|
+
import MultiSelectValidation from "./field-vise-validations/MultiSelectValidation";
|
|
12
|
+
import PercentValidation from "./field-vise-validations/PercentValidation";
|
|
13
|
+
import PicklistValidation from "./field-vise-validations/PicklistValidation";
|
|
14
|
+
import URLValidation from "./field-vise-validations/URLValidation";
|
|
15
|
+
import PhoneValidation from "./field-vise-validations/PhoneValidation";
|
|
16
|
+
import LookUpValidation from "./field-vise-validations/LookUpValidation";
|
|
17
|
+
const fieldValidationMap = {
|
|
18
|
+
[FieldTypes.TextBox]: new TextBoxValidation(),
|
|
19
|
+
[FieldTypes.TextArea]: new TextAreaValidation(),
|
|
20
|
+
[FieldTypes.Email]: new EmailValidation(),
|
|
21
|
+
[FieldTypes.Currency]: new CurrencyValidation(),
|
|
22
|
+
[FieldTypes.Decimal]: new DecimalValidation(),
|
|
23
|
+
[FieldTypes.Integer]: new IntegerValidation(),
|
|
24
|
+
[FieldTypes.Phone]: new PhoneValidation(),
|
|
25
|
+
[FieldTypes.Date]: new DateValidation(),
|
|
26
|
+
[FieldTypes.DateTime]: new DateTimeValidation(),
|
|
27
|
+
[FieldTypes.Boolean]: new BooleanValidation(),
|
|
28
|
+
[FieldTypes.MultiSelect]: new MultiSelectValidation(),
|
|
29
|
+
[FieldTypes.Picklist]: new PicklistValidation(),
|
|
30
|
+
[FieldTypes.LookUp]: new LookUpValidation(),
|
|
31
|
+
[FieldTypes.Percent]: new PercentValidation(),
|
|
32
|
+
[FieldTypes.URL]: new URLValidation()
|
|
33
|
+
};
|
|
34
|
+
|
|
35
|
+
class FieldValidation {
|
|
36
|
+
constructor(validationsMap) {
|
|
37
|
+
this.validationsMap = validationsMap;
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
validateField(field, value) {
|
|
41
|
+
const validations = this.getFieldValidations(field);
|
|
42
|
+
return this.run(validations, value);
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
validateFields(fields) {
|
|
46
|
+
return fields.map(field => {
|
|
47
|
+
const validations = this.getFieldValidations(field);
|
|
48
|
+
return this.run(validations, field.value);
|
|
49
|
+
});
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
getFieldValidations(field) {
|
|
53
|
+
const {
|
|
54
|
+
type: fieldType
|
|
55
|
+
} = field;
|
|
56
|
+
const validator = fieldValidationMap[fieldType];
|
|
57
|
+
|
|
58
|
+
if (validator) {
|
|
59
|
+
return validator.getFieldValidations(field);
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
return [];
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
run(validations, value) {
|
|
66
|
+
const {
|
|
67
|
+
validationsMap
|
|
68
|
+
} = this;
|
|
69
|
+
const validationResults = validations.map(_ref => {
|
|
70
|
+
let {
|
|
71
|
+
methodName,
|
|
72
|
+
config
|
|
73
|
+
} = _ref;
|
|
74
|
+
return validationsMap[methodName](value, config);
|
|
75
|
+
});
|
|
76
|
+
return this.getValidationResult(validationResults);
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
getValidationResult(validationResults) {
|
|
80
|
+
let validationResult = {
|
|
81
|
+
isValid: true,
|
|
82
|
+
message: ''
|
|
83
|
+
};
|
|
84
|
+
validationResults.forEach(result => {
|
|
85
|
+
if (!result.isValid && validationResult.isValid) {
|
|
86
|
+
validationResult = result;
|
|
87
|
+
}
|
|
88
|
+
});
|
|
89
|
+
return validationResult;
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
export default FieldValidation;
|
package/es/library/behaviours/field-validation/domain/field-vise-validations/BooleanValidation.js
ADDED
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import ValidationsEnum from "../interfaces/ValidationsEnum";
|
|
2
|
+
|
|
3
|
+
class BooleanValidation {
|
|
4
|
+
getFieldValidations(field) {
|
|
5
|
+
const {
|
|
6
|
+
required
|
|
7
|
+
} = field;
|
|
8
|
+
const validations = [];
|
|
9
|
+
validations.push({
|
|
10
|
+
methodName: ValidationsEnum.boolean,
|
|
11
|
+
config: {}
|
|
12
|
+
});
|
|
13
|
+
|
|
14
|
+
if (required) {
|
|
15
|
+
validations.push({
|
|
16
|
+
methodName: ValidationsEnum.mandatory,
|
|
17
|
+
config: {
|
|
18
|
+
type: field.type
|
|
19
|
+
}
|
|
20
|
+
});
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
return validations;
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
export default BooleanValidation;
|
package/es/library/behaviours/field-validation/domain/field-vise-validations/CurrencyValidation.js
ADDED
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import ValidationsEnum from "../interfaces/ValidationsEnum";
|
|
2
|
+
|
|
3
|
+
class CurrencyValidation {
|
|
4
|
+
getFieldValidations(field) {
|
|
5
|
+
const {
|
|
6
|
+
required,
|
|
7
|
+
maxLength,
|
|
8
|
+
decimalPlaces
|
|
9
|
+
} = field;
|
|
10
|
+
const validations = [];
|
|
11
|
+
|
|
12
|
+
if (maxLength) {
|
|
13
|
+
validations.push({
|
|
14
|
+
methodName: ValidationsEnum.maxLength,
|
|
15
|
+
config: {
|
|
16
|
+
maxLength
|
|
17
|
+
}
|
|
18
|
+
});
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
if (decimalPlaces) {
|
|
22
|
+
validations.push({
|
|
23
|
+
methodName: ValidationsEnum.decimalPlaces,
|
|
24
|
+
config: {
|
|
25
|
+
decimalPlaces
|
|
26
|
+
}
|
|
27
|
+
});
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
validations.push({
|
|
31
|
+
methodName: ValidationsEnum.decimal,
|
|
32
|
+
config: {}
|
|
33
|
+
});
|
|
34
|
+
|
|
35
|
+
if (required) {
|
|
36
|
+
validations.push({
|
|
37
|
+
methodName: ValidationsEnum.mandatory,
|
|
38
|
+
config: {
|
|
39
|
+
type: field.type
|
|
40
|
+
}
|
|
41
|
+
});
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
return validations;
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
export default CurrencyValidation;
|
package/es/library/behaviours/field-validation/domain/field-vise-validations/DateTimeValidation.js
ADDED
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import ValidationsEnum from "../interfaces/ValidationsEnum";
|
|
2
|
+
|
|
3
|
+
class DateTimeValidation {
|
|
4
|
+
getFieldValidations(field) {
|
|
5
|
+
const validations = [];
|
|
6
|
+
const {
|
|
7
|
+
required
|
|
8
|
+
} = field;
|
|
9
|
+
|
|
10
|
+
if (required) {
|
|
11
|
+
validations.push({
|
|
12
|
+
methodName: ValidationsEnum.mandatory,
|
|
13
|
+
config: {
|
|
14
|
+
type: field.type
|
|
15
|
+
}
|
|
16
|
+
});
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
return validations;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
export default DateTimeValidation;
|
package/es/library/behaviours/field-validation/domain/field-vise-validations/DateValidation.js
ADDED
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import ValidationsEnum from "../interfaces/ValidationsEnum";
|
|
2
|
+
|
|
3
|
+
class DateValidation {
|
|
4
|
+
getFieldValidations(field) {
|
|
5
|
+
const validations = [];
|
|
6
|
+
const {
|
|
7
|
+
required
|
|
8
|
+
} = field;
|
|
9
|
+
|
|
10
|
+
if (required) {
|
|
11
|
+
validations.push({
|
|
12
|
+
methodName: ValidationsEnum.mandatory,
|
|
13
|
+
config: {
|
|
14
|
+
type: field.type
|
|
15
|
+
}
|
|
16
|
+
});
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
return validations;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
export default DateValidation;
|
package/es/library/behaviours/field-validation/domain/field-vise-validations/DecimalValidation.js
ADDED
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import ValidationsEnum from "../interfaces/ValidationsEnum";
|
|
2
|
+
|
|
3
|
+
class DecimalValidation {
|
|
4
|
+
getFieldValidations(field) {
|
|
5
|
+
const {
|
|
6
|
+
required,
|
|
7
|
+
maxLength,
|
|
8
|
+
decimalPlaces
|
|
9
|
+
} = field;
|
|
10
|
+
const validations = [];
|
|
11
|
+
|
|
12
|
+
if (maxLength) {
|
|
13
|
+
validations.push({
|
|
14
|
+
methodName: ValidationsEnum.maxLength,
|
|
15
|
+
config: {
|
|
16
|
+
maxLength
|
|
17
|
+
}
|
|
18
|
+
});
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
if (decimalPlaces) {
|
|
22
|
+
validations.push({
|
|
23
|
+
methodName: ValidationsEnum.decimalPlaces,
|
|
24
|
+
config: {
|
|
25
|
+
decimalPlaces
|
|
26
|
+
}
|
|
27
|
+
});
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
validations.push({
|
|
31
|
+
methodName: ValidationsEnum.decimal,
|
|
32
|
+
config: {}
|
|
33
|
+
});
|
|
34
|
+
|
|
35
|
+
if (required) {
|
|
36
|
+
validations.push({
|
|
37
|
+
methodName: ValidationsEnum.mandatory,
|
|
38
|
+
config: {
|
|
39
|
+
type: field.type
|
|
40
|
+
}
|
|
41
|
+
});
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
return validations;
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
export default DecimalValidation;
|