@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.
Files changed (145) hide show
  1. package/es/bc/field-validation/Constants.js +4 -0
  2. package/es/bc/field-validation/EventHandlers.js +1 -0
  3. package/es/bc/field-validation/Events.js +106 -0
  4. package/es/bc/field-validation/FieldTypes.js +20 -0
  5. package/es/bc/field-validation/Properties.js +11 -0
  6. package/es/bc/field-validation/index.js +5 -0
  7. package/es/cc/ephi-tag/Properties.js +1 -0
  8. package/es/cc/ephi-tag/index.js +1 -0
  9. package/es/cc/info-icon/Properties.js +10 -0
  10. package/es/cc/info-icon/index.js +1 -0
  11. package/es/{platform/app-context-behaviour → library/behaviours/field-validation}/adapters/controllers/AbstractController.js +4 -2
  12. package/es/library/behaviours/field-validation/adapters/controllers/ValidateFieldController.js +32 -0
  13. package/es/library/behaviours/field-validation/adapters/controllers/ValidateFieldsController.js +31 -0
  14. package/es/library/behaviours/field-validation/adapters/gateway/Repository.js +23 -0
  15. package/es/library/behaviours/field-validation/adapters/gateway/Service.js +18 -0
  16. package/es/library/behaviours/field-validation/applications/interfaces/input/FieldData.js +17 -0
  17. package/es/library/behaviours/field-validation/applications/usecases/AbstractUseCase.js +15 -0
  18. package/es/library/behaviours/field-validation/applications/usecases/ValidateField.js +29 -0
  19. package/es/library/behaviours/field-validation/applications/usecases/ValidateFields.js +28 -0
  20. package/es/library/behaviours/field-validation/domain/FieldValidation.js +94 -0
  21. package/es/library/behaviours/field-validation/domain/field-vise-validations/BooleanValidation.js +28 -0
  22. package/es/library/behaviours/field-validation/domain/field-vise-validations/CurrencyValidation.js +49 -0
  23. package/es/library/behaviours/field-validation/domain/field-vise-validations/DateTimeValidation.js +24 -0
  24. package/es/library/behaviours/field-validation/domain/field-vise-validations/DateValidation.js +24 -0
  25. package/es/library/behaviours/field-validation/domain/field-vise-validations/DecimalValidation.js +49 -0
  26. package/es/library/behaviours/field-validation/domain/field-vise-validations/EmailValidation.js +28 -0
  27. package/es/library/behaviours/field-validation/domain/field-vise-validations/IntegerValidation.js +39 -0
  28. package/es/library/behaviours/field-validation/domain/field-vise-validations/LookUpValidation.js +24 -0
  29. package/es/library/behaviours/field-validation/domain/field-vise-validations/MultiSelectValidation.js +26 -0
  30. package/es/library/behaviours/field-validation/domain/field-vise-validations/PercentValidation.js +28 -0
  31. package/es/library/behaviours/field-validation/domain/field-vise-validations/PhoneValidation.js +39 -0
  32. package/es/library/behaviours/field-validation/domain/field-vise-validations/PicklistValidation.js +24 -0
  33. package/es/library/behaviours/field-validation/domain/field-vise-validations/TextAreaValidation.js +39 -0
  34. package/es/library/behaviours/field-validation/domain/field-vise-validations/TextBoxValidation.js +39 -0
  35. package/es/library/behaviours/field-validation/domain/field-vise-validations/URLValidation.js +28 -0
  36. package/es/library/behaviours/field-validation/domain/interfaces/FieldTypes.js +20 -0
  37. package/es/library/behaviours/field-validation/domain/interfaces/ValidationsEnum.js +22 -0
  38. package/es/library/behaviours/field-validation/domain/interfaces/ValidationsMap.js +1 -0
  39. package/es/library/behaviours/field-validation/domain/interfaces/fields/IDateField.js +0 -0
  40. package/es/library/behaviours/field-validation/domain/interfaces/fields/IDateTimeField.js +0 -0
  41. package/es/library/behaviours/field-validation/domain/interfaces/fields/IDecimalField.js +0 -0
  42. package/es/library/behaviours/field-validation/domain/interfaces/fields/IEmailField.js +0 -0
  43. package/es/library/behaviours/field-validation/domain/interfaces/fields/IIntegerField.js +0 -0
  44. package/es/library/behaviours/field-validation/domain/interfaces/fields/ILookUpField.js +0 -0
  45. package/es/library/behaviours/field-validation/domain/interfaces/fields/IMultiSelectField.js +0 -0
  46. package/es/library/behaviours/field-validation/domain/interfaces/fields/IPercentField.js +0 -0
  47. package/es/library/behaviours/field-validation/domain/interfaces/fields/IPhoneField.js +0 -0
  48. package/es/library/behaviours/field-validation/domain/interfaces/fields/IPicklistField.js +0 -0
  49. package/es/library/behaviours/field-validation/domain/interfaces/fields/ITextAreaField.js +0 -0
  50. package/es/library/behaviours/field-validation/domain/interfaces/fields/ITextBoxField.js +0 -0
  51. package/es/library/behaviours/field-validation/domain/interfaces/fields/IURLField.js +0 -0
  52. package/es/library/behaviours/field-validation/frameworks/ui/EventHandlerFactory.js +23 -0
  53. package/es/library/behaviours/field-validation/frameworks/ui/FieldValidationBehaviourFactory.js +27 -0
  54. package/es/library/behaviours/field-validation/frameworks/ui/__tests__/BooleanFieldValidation.test.js +137 -0
  55. package/es/library/behaviours/field-validation/frameworks/ui/__tests__/CurrencyFieldValidation.test.js +228 -0
  56. package/es/library/behaviours/field-validation/frameworks/ui/__tests__/DateFieldValidation.test.js +108 -0
  57. package/es/library/behaviours/field-validation/frameworks/ui/__tests__/DateTimeFieldValidation.test.js +108 -0
  58. package/es/library/behaviours/field-validation/frameworks/ui/__tests__/DecimalFieldValidation.test.js +257 -0
  59. package/es/library/behaviours/field-validation/frameworks/ui/__tests__/EmailFieldValidation.test.js +139 -0
  60. package/es/library/behaviours/field-validation/frameworks/ui/__tests__/FieldValidationBehaviour.test.js +171 -0
  61. package/es/library/behaviours/field-validation/frameworks/ui/__tests__/IntegerFieldValidation.test.js +168 -0
  62. package/es/library/behaviours/field-validation/frameworks/ui/__tests__/LookUpFieldValidation.test.js +108 -0
  63. package/es/library/behaviours/field-validation/frameworks/ui/__tests__/MultiSelectFieldValidation.test.js +79 -0
  64. package/es/library/behaviours/field-validation/frameworks/ui/__tests__/PercentFieldValidation.test.js +108 -0
  65. package/es/library/behaviours/field-validation/frameworks/ui/__tests__/PhoneFieldValidation.test.js +168 -0
  66. package/es/library/behaviours/field-validation/frameworks/ui/__tests__/PicklistFieldValidation.test.js +79 -0
  67. package/es/library/behaviours/field-validation/frameworks/ui/__tests__/TextAreaFieldValidation.test.js +170 -0
  68. package/es/library/behaviours/field-validation/frameworks/ui/__tests__/TextBoxFieldValidation.test.js +170 -0
  69. package/es/library/behaviours/field-validation/frameworks/ui/__tests__/URLFieldValidation.test.js +108 -0
  70. package/es/library/behaviours/field-validation/frameworks/utils/FormBasicValidationAdaptor.js +228 -0
  71. package/es/library/behaviours/field-validation/frameworks/utils/__tests__/formValidate.test.js +284 -0
  72. package/es/library/behaviours/field-validation/frameworks/utils/formValidate.js +334 -0
  73. package/es/library/dot/components/form-fields/checkbox/adapters/presenter/TransformState.js +22 -0
  74. package/es/library/dot/components/form-fields/currency/adapters/presenter/TransformState.js +81 -0
  75. package/es/library/dot/components/form-fields/date/adapters/presenter/TransformState.js +22 -0
  76. package/es/library/dot/components/form-fields/datetime/adapters/presenter/TransformState.js +22 -0
  77. package/es/library/dot/components/form-fields/decimal/adapters/presenter/TransformState.js +31 -0
  78. package/es/library/dot/components/form-fields/email/adapters/presenter/TransformState.js +23 -0
  79. package/es/library/dot/components/form-fields/ephi-tag/frameworks/ui/EPHITag.js +10 -0
  80. package/es/library/dot/components/form-fields/ephi-tag/frameworks/ui/EPHITagView.js +21 -0
  81. package/es/library/dot/components/form-fields/ephi-tag/frameworks/ui/css/EPHITag.module.css +3 -0
  82. package/es/library/dot/components/form-fields/info-icon/frameworks/ui/InfoIcon.js +10 -0
  83. package/es/library/dot/components/form-fields/info-icon/frameworks/ui/InfoIconView.js +21 -0
  84. package/es/library/dot/components/form-fields/info-icon/frameworks/ui/css/InfoIcon.module.css +3 -0
  85. package/es/library/dot/components/form-fields/multi-select/adapters/presenter/TransformState.js +31 -0
  86. package/es/library/dot/components/form-fields/number/adapters/presenter/TransformState.js +31 -0
  87. package/es/library/dot/components/form-fields/percentage/adapters/presenter/TransformState.js +31 -0
  88. package/es/library/dot/components/form-fields/phone/adapters/presenter/TransformState.js +31 -0
  89. package/es/library/dot/components/form-fields/pick-list/adapters/presenter/TransformState.js +23 -0
  90. package/es/library/dot/components/form-fields/textarea/adapters/presenter/TransformState.js +23 -0
  91. package/es/library/dot/components/form-fields/textbox/adapters/presenter/TransformState.js +32 -0
  92. package/es/library/dot/components/form-fields/url/adapters/presenter/TransformState.js +31 -0
  93. package/es/library/dot/components/section/adapters/presenter/TransFormState.js +26 -0
  94. package/es/library/dot/legacy-to-new-arch/label/frameworks/ui/sub-components/ui/LabelAction.js +9 -0
  95. package/es/library/dot/legacy-to-new-arch/label/frameworks/ui/sub-components/ui/LabelActionView.js +38 -0
  96. package/es/library/dot/legacy-to-new-arch/label/frameworks/ui/sub-components/ui/css/LabelAction.module.css +4 -0
  97. package/es/platform/components/form-connected/adapters/resources/SmartFormResources.js +18 -0
  98. package/es/platform/components/form-connected/frameworks/FormSdkFactory.js +4 -2
  99. package/es/platform/zdata-source/domain/entities/APITemplate.js +2 -1
  100. package/es/platform/zform/adapters/controllers/ValidateErrorMessageController.js +22 -0
  101. package/es/platform/zform/applications/interfaces/input/GetIsFieldValueChangedUseCaseInput.js +1 -0
  102. package/es/platform/zform/applications/interfaces/input/ValidateErrorMessageInputModel.js +1 -0
  103. package/es/platform/zform/applications/usecases/GetIsFieldValueChanged.js +35 -0
  104. package/es/platform/zform/applications/usecases/ValidateErrorMessageUseCase.js +33 -0
  105. package/es/platform/zform/applications/usecases/ValidateFieldRequestUseCase.js +56 -0
  106. package/es/platform/zform/domain/ZField.js +4 -0
  107. package/package.json +1 -1
  108. package/es/bc/app-context/Event.js +0 -1
  109. package/es/bc/app-context/Properties.js +0 -58
  110. package/es/cc/component/ErrorStructure.js +0 -9
  111. package/es/cc/error-state/ErrorTypes.js +0 -11
  112. package/es/cc/error-state/Properties.js +0 -31
  113. package/es/cc/error-state/index.js +0 -2
  114. package/es/library/custom-component/domain/entities/ComponentProperties.js +0 -121
  115. package/es/library/custom-component/domain/entities/Logger.js +0 -63
  116. package/es/library/dot/legacy-to-new-arch/error-state/frameworks/ui/ErrorState.js +0 -10
  117. package/es/library/dot/legacy-to-new-arch/error-state/frameworks/ui/ErrorStateView.js +0 -68
  118. package/es/platform/app-context-behaviour/adapters/controllers/InitializeController.js +0 -19
  119. package/es/platform/app-context-behaviour/adapters/gateways/Service.js +0 -7
  120. package/es/platform/app-context-behaviour/adapters/presenters/Presenter.js +0 -18
  121. package/es/platform/app-context-behaviour/adapters/resources/AppResource.js +0 -25
  122. package/es/platform/app-context-behaviour/applications/AbstractUseCase.js +0 -6
  123. package/es/platform/app-context-behaviour/applications/usecases/InitializeUseCase.js +0 -15
  124. package/es/platform/app-context-behaviour/frameworks/AppContextBehaviourFactory.js +0 -31
  125. package/es/platform/app-context-behaviour/frameworks/EventHandlerFactory.js +0 -25
  126. package/es/platform/components/form-connected/frameworks/FallbackView.js +0 -23
  127. package/es/platform/data-source/http-template/getDependencyMappings.js +0 -18
  128. package/es/platform/data-source/http-template/getLayoutRules.js +0 -29
  129. package/es/platform/data-source/http-template/getMyForm.js +0 -19
  130. package/es/platform/data-source/http-template/getMyLayout.js +0 -43
  131. package/es/platform/data-source/http-template/getValidationRules.js +0 -30
  132. package/es/platform/zform/adapters/controllers/ApiFailureController.js +0 -31
  133. package/es/platform/zform/applications/usecases/ApiFailureUseCase.js +0 -30
  134. /package/es/{platform/app-context-behaviour/applications/interfaces/UsecaseDependencies.js → library/behaviours/field-validation/applications/interfaces/UseCaseDependencies.js} +0 -0
  135. /package/es/{platform/app-context-behaviour/applications/interfaces/gateways/IService.js → library/behaviours/field-validation/applications/interfaces/gateways/IRepository.js} +0 -0
  136. /package/es/{platform/app-context-behaviour/applications/interfaces/input/InitializeUseCaseInputModel.js → library/behaviours/field-validation/applications/interfaces/gateways/IService.js} +0 -0
  137. /package/es/{platform/app-context-behaviour/applications/interfaces/output/BehaviourState.js → library/behaviours/field-validation/applications/interfaces/input/FieldValidationInputModel.js} +0 -0
  138. /package/es/{platform/app-context-behaviour/applications/interfaces/output/IPresenter.js → library/behaviours/field-validation/applications/interfaces/input/ValidateFieldsInputModel.js} +0 -0
  139. /package/es/{bc/app-context/Constants.js → library/behaviours/field-validation/domain/interfaces/IField.js} +0 -0
  140. /package/es/{platform/app-context-behaviour/applications/interfaces/resources/ApiHeaderContract.js → library/behaviours/field-validation/domain/interfaces/IFieldValidation.js} +0 -0
  141. /package/es/{platform/app-context-behaviour/applications/interfaces/resources/ContextContract.js → library/behaviours/field-validation/domain/interfaces/IFieldViseValidation.js} +0 -0
  142. /package/es/{platform/app-context-behaviour/applications/interfaces/resources/IAppResource.js → library/behaviours/field-validation/domain/interfaces/ValidationResult.js} +0 -0
  143. /package/es/{platform/zform/applications/interfaces/input/ApiFailureInputModel.js → library/behaviours/field-validation/domain/interfaces/ValidationsArray.js} +0 -0
  144. /package/es/{bc/app-context/EventHandlers.js → library/behaviours/field-validation/domain/interfaces/fields/IBooleanField.js} +0 -0
  145. /package/es/library/{custom-component/domain/entities/interfaces/IComponentProperties.js → behaviours/field-validation/domain/interfaces/fields/ICurrencyField.js} +0 -0
@@ -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;
@@ -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;
@@ -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;
@@ -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;
@@ -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;
@@ -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;
@@ -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;
@@ -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,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;
@@ -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
+ });