@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
package/es/library/behaviours/field-validation/domain/field-vise-validations/EmailValidation.js
ADDED
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import ValidationsEnum from "../interfaces/ValidationsEnum";
|
|
2
|
+
|
|
3
|
+
class EmailValidation {
|
|
4
|
+
getFieldValidations(field) {
|
|
5
|
+
const {
|
|
6
|
+
required
|
|
7
|
+
} = field;
|
|
8
|
+
const validations = [];
|
|
9
|
+
validations.push({
|
|
10
|
+
methodName: ValidationsEnum.email,
|
|
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 EmailValidation;
|
package/es/library/behaviours/field-validation/domain/field-vise-validations/IntegerValidation.js
ADDED
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import ValidationsEnum from "../interfaces/ValidationsEnum";
|
|
2
|
+
|
|
3
|
+
class IntegerValidation {
|
|
4
|
+
getFieldValidations(field) {
|
|
5
|
+
const validations = [];
|
|
6
|
+
const {
|
|
7
|
+
required,
|
|
8
|
+
maxLength
|
|
9
|
+
} = field;
|
|
10
|
+
|
|
11
|
+
if (maxLength) {
|
|
12
|
+
validations.push({
|
|
13
|
+
methodName: ValidationsEnum.maxLength,
|
|
14
|
+
config: {
|
|
15
|
+
maxLength
|
|
16
|
+
}
|
|
17
|
+
});
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
validations.push({
|
|
21
|
+
methodName: ValidationsEnum.integer,
|
|
22
|
+
config: {}
|
|
23
|
+
});
|
|
24
|
+
|
|
25
|
+
if (required) {
|
|
26
|
+
validations.push({
|
|
27
|
+
methodName: ValidationsEnum.mandatory,
|
|
28
|
+
config: {
|
|
29
|
+
type: field.type
|
|
30
|
+
}
|
|
31
|
+
});
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
return validations;
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
export default IntegerValidation;
|
package/es/library/behaviours/field-validation/domain/field-vise-validations/LookUpValidation.js
ADDED
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import ValidationsEnum from "../interfaces/ValidationsEnum";
|
|
2
|
+
|
|
3
|
+
class LookUpValidation {
|
|
4
|
+
getFieldValidations(field) {
|
|
5
|
+
const {
|
|
6
|
+
required
|
|
7
|
+
} = field;
|
|
8
|
+
const validations = []; // validations.push({ methodName: ValidationsEnum.lookUp, config: {} });
|
|
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 LookUpValidation;
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import ValidationsEnum from "../interfaces/ValidationsEnum";
|
|
2
|
+
|
|
3
|
+
class MultiSelectValidation {
|
|
4
|
+
getFieldValidations(field) {
|
|
5
|
+
const {
|
|
6
|
+
required
|
|
7
|
+
} = field;
|
|
8
|
+
const validations = []; // if (maxSelections) {
|
|
9
|
+
// validations.push({ methodName: ValidationsEnum.maxSelections, config: { maxSelections } });
|
|
10
|
+
// }
|
|
11
|
+
|
|
12
|
+
if (required) {
|
|
13
|
+
validations.push({
|
|
14
|
+
methodName: ValidationsEnum.mandatory,
|
|
15
|
+
config: {
|
|
16
|
+
type: field.type
|
|
17
|
+
}
|
|
18
|
+
});
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
return validations;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
export default MultiSelectValidation;
|
package/es/library/behaviours/field-validation/domain/field-vise-validations/PercentValidation.js
ADDED
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import ValidationsEnum from "../interfaces/ValidationsEnum";
|
|
2
|
+
|
|
3
|
+
class PercentValidation {
|
|
4
|
+
getFieldValidations(field) {
|
|
5
|
+
const validations = [];
|
|
6
|
+
const {
|
|
7
|
+
required
|
|
8
|
+
} = field;
|
|
9
|
+
validations.push({
|
|
10
|
+
methodName: ValidationsEnum.percent,
|
|
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 PercentValidation;
|
package/es/library/behaviours/field-validation/domain/field-vise-validations/PhoneValidation.js
ADDED
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import ValidationsEnum from "../interfaces/ValidationsEnum";
|
|
2
|
+
|
|
3
|
+
class PhoneValidation {
|
|
4
|
+
getFieldValidations(field) {
|
|
5
|
+
const {
|
|
6
|
+
required,
|
|
7
|
+
maxLength
|
|
8
|
+
} = field;
|
|
9
|
+
const validations = [];
|
|
10
|
+
|
|
11
|
+
if (maxLength) {
|
|
12
|
+
validations.push({
|
|
13
|
+
methodName: ValidationsEnum.maxLength,
|
|
14
|
+
config: {
|
|
15
|
+
maxLength
|
|
16
|
+
}
|
|
17
|
+
});
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
validations.push({
|
|
21
|
+
methodName: ValidationsEnum.phone,
|
|
22
|
+
config: {}
|
|
23
|
+
});
|
|
24
|
+
|
|
25
|
+
if (required) {
|
|
26
|
+
validations.push({
|
|
27
|
+
methodName: ValidationsEnum.mandatory,
|
|
28
|
+
config: {
|
|
29
|
+
type: field.type
|
|
30
|
+
}
|
|
31
|
+
});
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
return validations;
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
export default PhoneValidation;
|
package/es/library/behaviours/field-validation/domain/field-vise-validations/PicklistValidation.js
ADDED
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import ValidationsEnum from "../interfaces/ValidationsEnum";
|
|
2
|
+
|
|
3
|
+
class PicklistValidation {
|
|
4
|
+
getFieldValidations(field) {
|
|
5
|
+
const {
|
|
6
|
+
required
|
|
7
|
+
} = field;
|
|
8
|
+
const validations = [];
|
|
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 PicklistValidation;
|
package/es/library/behaviours/field-validation/domain/field-vise-validations/TextAreaValidation.js
ADDED
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import ValidationsEnum from "../interfaces/ValidationsEnum";
|
|
2
|
+
|
|
3
|
+
class TextAreaValidation {
|
|
4
|
+
getFieldValidations(field) {
|
|
5
|
+
const validations = [];
|
|
6
|
+
const {
|
|
7
|
+
required,
|
|
8
|
+
maxLength
|
|
9
|
+
} = field;
|
|
10
|
+
|
|
11
|
+
if (maxLength) {
|
|
12
|
+
validations.push({
|
|
13
|
+
methodName: ValidationsEnum.maxLength,
|
|
14
|
+
config: {
|
|
15
|
+
maxLength
|
|
16
|
+
}
|
|
17
|
+
});
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
validations.push({
|
|
21
|
+
methodName: ValidationsEnum.textArea,
|
|
22
|
+
config: {}
|
|
23
|
+
});
|
|
24
|
+
|
|
25
|
+
if (required) {
|
|
26
|
+
validations.push({
|
|
27
|
+
methodName: ValidationsEnum.mandatory,
|
|
28
|
+
config: {
|
|
29
|
+
type: field.type
|
|
30
|
+
}
|
|
31
|
+
});
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
return validations;
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
export default TextAreaValidation;
|
package/es/library/behaviours/field-validation/domain/field-vise-validations/TextBoxValidation.js
ADDED
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import ValidationsEnum from "../interfaces/ValidationsEnum";
|
|
2
|
+
|
|
3
|
+
class TextBoxValidation {
|
|
4
|
+
getFieldValidations(field) {
|
|
5
|
+
const validations = [];
|
|
6
|
+
const {
|
|
7
|
+
required,
|
|
8
|
+
maxLength
|
|
9
|
+
} = field;
|
|
10
|
+
|
|
11
|
+
if (maxLength) {
|
|
12
|
+
validations.push({
|
|
13
|
+
methodName: ValidationsEnum.maxLength,
|
|
14
|
+
config: {
|
|
15
|
+
maxLength
|
|
16
|
+
}
|
|
17
|
+
});
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
validations.push({
|
|
21
|
+
methodName: ValidationsEnum.text,
|
|
22
|
+
config: {}
|
|
23
|
+
});
|
|
24
|
+
|
|
25
|
+
if (required) {
|
|
26
|
+
validations.push({
|
|
27
|
+
methodName: ValidationsEnum.mandatory,
|
|
28
|
+
config: {
|
|
29
|
+
type: field.type
|
|
30
|
+
}
|
|
31
|
+
});
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
return validations;
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
export default TextBoxValidation;
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import ValidationsEnum from "../interfaces/ValidationsEnum";
|
|
2
|
+
|
|
3
|
+
class URLValidation {
|
|
4
|
+
getFieldValidations(field) {
|
|
5
|
+
const {
|
|
6
|
+
required
|
|
7
|
+
} = field;
|
|
8
|
+
const validations = [];
|
|
9
|
+
validations.push({
|
|
10
|
+
methodName: ValidationsEnum.url,
|
|
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 URLValidation;
|
|
@@ -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,22 @@
|
|
|
1
|
+
var ValidationsEnum = /*#__PURE__*/function (ValidationsEnum) {
|
|
2
|
+
ValidationsEnum["mandatory"] = "mandatory";
|
|
3
|
+
ValidationsEnum["maxLength"] = "maxLength";
|
|
4
|
+
ValidationsEnum["text"] = "text";
|
|
5
|
+
ValidationsEnum["textArea"] = "textArea";
|
|
6
|
+
ValidationsEnum["email"] = "email";
|
|
7
|
+
ValidationsEnum["decimalPlaces"] = "decimalPlaces";
|
|
8
|
+
ValidationsEnum["phone"] = "phone";
|
|
9
|
+
ValidationsEnum["integer"] = "integer";
|
|
10
|
+
ValidationsEnum["decimal"] = "decimal";
|
|
11
|
+
ValidationsEnum["date"] = "date";
|
|
12
|
+
ValidationsEnum["dateTime"] = "dateTime";
|
|
13
|
+
ValidationsEnum["boolean"] = "boolean";
|
|
14
|
+
ValidationsEnum["multiSelect"] = "multiSelect";
|
|
15
|
+
ValidationsEnum["picklist"] = "picklist";
|
|
16
|
+
ValidationsEnum["percent"] = "percent";
|
|
17
|
+
ValidationsEnum["currency"] = "currency";
|
|
18
|
+
ValidationsEnum["url"] = "url";
|
|
19
|
+
return ValidationsEnum;
|
|
20
|
+
}(ValidationsEnum || {});
|
|
21
|
+
|
|
22
|
+
export default ValidationsEnum;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { VALIDATE_FIELD, VALIDATE_FIELDS } from "../../../../../bc/field-validation/Constants";
|
|
2
|
+
import ValidateFieldController from "../../adapters/controllers/ValidateFieldController";
|
|
3
|
+
import Repository from "../../adapters/gateway/Repository";
|
|
4
|
+
import Service from "../../adapters/gateway/Service";
|
|
5
|
+
import ValidateFieldsController from "../../adapters/controllers/ValidateFieldsController";
|
|
6
|
+
|
|
7
|
+
class EventHandlersFactory {
|
|
8
|
+
static create() {
|
|
9
|
+
const repository = new Repository();
|
|
10
|
+
const service = new Service({
|
|
11
|
+
repository
|
|
12
|
+
});
|
|
13
|
+
const validateFieldController = new ValidateFieldController(service);
|
|
14
|
+
const validateFieldsController = new ValidateFieldsController(service);
|
|
15
|
+
return {
|
|
16
|
+
[VALIDATE_FIELD]: validateFieldController.handle,
|
|
17
|
+
[VALIDATE_FIELDS]: validateFieldsController.handle
|
|
18
|
+
};
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
export default EventHandlersFactory;
|
package/es/library/behaviours/field-validation/frameworks/ui/FieldValidationBehaviourFactory.js
ADDED
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import Properties from "../../../../../bc/field-validation/Properties";
|
|
2
|
+
import EventHandlerFactory from "./EventHandlerFactory";
|
|
3
|
+
|
|
4
|
+
class FieldValidationBehaviourFactory {
|
|
5
|
+
static create() {
|
|
6
|
+
return {
|
|
7
|
+
name: 'fieldValidation',
|
|
8
|
+
setInitialState: _ref => {
|
|
9
|
+
let {
|
|
10
|
+
properties
|
|
11
|
+
} = _ref;
|
|
12
|
+
const {
|
|
13
|
+
validations
|
|
14
|
+
} = properties;
|
|
15
|
+
return {
|
|
16
|
+
validations,
|
|
17
|
+
errors: {}
|
|
18
|
+
};
|
|
19
|
+
},
|
|
20
|
+
properties: Properties,
|
|
21
|
+
eventHandlers: EventHandlerFactory.create()
|
|
22
|
+
};
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
export default FieldValidationBehaviourFactory;
|
|
@@ -0,0 +1,137 @@
|
|
|
1
|
+
import { VALIDATE_FIELD, FIELD_VALIDATION_RESULT } from "../../../../../../bc/field-validation/Constants";
|
|
2
|
+
import FieldValidationBehaviourFactory from "../FieldValidationBehaviourFactory";
|
|
3
|
+
import { validations } from "../../utils/FormBasicValidationAdaptor";
|
|
4
|
+
import FieldTypes from "../../../../../../bc/field-validation/FieldTypes";
|
|
5
|
+
describe('Boolean FieldValidationBehaviour', () => {
|
|
6
|
+
let behaviour;
|
|
7
|
+
let state;
|
|
8
|
+
let updateState;
|
|
9
|
+
let dispatch;
|
|
10
|
+
beforeEach(() => {
|
|
11
|
+
behaviour = FieldValidationBehaviourFactory.create();
|
|
12
|
+
state = {
|
|
13
|
+
properties: {
|
|
14
|
+
validations
|
|
15
|
+
}
|
|
16
|
+
};
|
|
17
|
+
updateState = jest.fn();
|
|
18
|
+
dispatch = jest.fn();
|
|
19
|
+
});
|
|
20
|
+
it('should validate Boolean mandatory field and return error', () => {
|
|
21
|
+
const field = {
|
|
22
|
+
id: 'boolean',
|
|
23
|
+
type: FieldTypes.Boolean,
|
|
24
|
+
required: true
|
|
25
|
+
};
|
|
26
|
+
const event = {
|
|
27
|
+
state,
|
|
28
|
+
updateState,
|
|
29
|
+
action: {
|
|
30
|
+
type: VALIDATE_FIELD,
|
|
31
|
+
payload: {
|
|
32
|
+
field,
|
|
33
|
+
value: ''
|
|
34
|
+
}
|
|
35
|
+
},
|
|
36
|
+
dispatch
|
|
37
|
+
};
|
|
38
|
+
behaviour.eventHandlers[VALIDATE_FIELD](event);
|
|
39
|
+
expect(dispatch).toHaveBeenCalledWith({
|
|
40
|
+
type: FIELD_VALIDATION_RESULT,
|
|
41
|
+
payload: {
|
|
42
|
+
validationResult: {
|
|
43
|
+
isValid: false,
|
|
44
|
+
message: 'This field is required.'
|
|
45
|
+
},
|
|
46
|
+
field
|
|
47
|
+
}
|
|
48
|
+
});
|
|
49
|
+
});
|
|
50
|
+
it('should be valid boolean when value in true and return true', () => {
|
|
51
|
+
const field = {
|
|
52
|
+
id: 'boolean',
|
|
53
|
+
type: FieldTypes.Boolean
|
|
54
|
+
};
|
|
55
|
+
const event = {
|
|
56
|
+
state,
|
|
57
|
+
updateState,
|
|
58
|
+
action: {
|
|
59
|
+
type: VALIDATE_FIELD,
|
|
60
|
+
payload: {
|
|
61
|
+
field,
|
|
62
|
+
value: true
|
|
63
|
+
}
|
|
64
|
+
},
|
|
65
|
+
dispatch
|
|
66
|
+
};
|
|
67
|
+
behaviour.eventHandlers[VALIDATE_FIELD](event);
|
|
68
|
+
expect(dispatch).toHaveBeenCalledWith({
|
|
69
|
+
type: FIELD_VALIDATION_RESULT,
|
|
70
|
+
payload: {
|
|
71
|
+
validationResult: {
|
|
72
|
+
isValid: true,
|
|
73
|
+
message: ''
|
|
74
|
+
},
|
|
75
|
+
field
|
|
76
|
+
}
|
|
77
|
+
});
|
|
78
|
+
});
|
|
79
|
+
it('should be valid boolean when value in false and return true', () => {
|
|
80
|
+
const field = {
|
|
81
|
+
id: 'boolean',
|
|
82
|
+
type: FieldTypes.Boolean
|
|
83
|
+
};
|
|
84
|
+
const event = {
|
|
85
|
+
state,
|
|
86
|
+
updateState,
|
|
87
|
+
action: {
|
|
88
|
+
type: VALIDATE_FIELD,
|
|
89
|
+
payload: {
|
|
90
|
+
field,
|
|
91
|
+
value: false
|
|
92
|
+
}
|
|
93
|
+
},
|
|
94
|
+
dispatch
|
|
95
|
+
};
|
|
96
|
+
behaviour.eventHandlers[VALIDATE_FIELD](event);
|
|
97
|
+
expect(dispatch).toHaveBeenCalledWith({
|
|
98
|
+
type: FIELD_VALIDATION_RESULT,
|
|
99
|
+
payload: {
|
|
100
|
+
validationResult: {
|
|
101
|
+
isValid: true,
|
|
102
|
+
message: ''
|
|
103
|
+
},
|
|
104
|
+
field
|
|
105
|
+
}
|
|
106
|
+
});
|
|
107
|
+
});
|
|
108
|
+
xit('should validate invalid boolean and return false', () => {
|
|
109
|
+
const field = {
|
|
110
|
+
id: 'boolean',
|
|
111
|
+
type: FieldTypes.Boolean
|
|
112
|
+
};
|
|
113
|
+
const event = {
|
|
114
|
+
state,
|
|
115
|
+
updateState,
|
|
116
|
+
action: {
|
|
117
|
+
type: VALIDATE_FIELD,
|
|
118
|
+
payload: {
|
|
119
|
+
field,
|
|
120
|
+
value: 'invalid'
|
|
121
|
+
}
|
|
122
|
+
},
|
|
123
|
+
dispatch
|
|
124
|
+
};
|
|
125
|
+
behaviour.eventHandlers[VALIDATE_FIELD](event);
|
|
126
|
+
expect(dispatch).toHaveBeenCalledWith({
|
|
127
|
+
type: FIELD_VALIDATION_RESULT,
|
|
128
|
+
payload: {
|
|
129
|
+
validationResult: {
|
|
130
|
+
isValid: false,
|
|
131
|
+
message: 'Invalid boolean format'
|
|
132
|
+
},
|
|
133
|
+
field
|
|
134
|
+
}
|
|
135
|
+
});
|
|
136
|
+
});
|
|
137
|
+
});
|