@digigov/form 0.6.10 → 0.7.0

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 (108) hide show
  1. package/CHANGELOG.md +12 -1
  2. package/Field/FieldBase.js +110 -0
  3. package/Field/FieldConditional.js +72 -0
  4. package/Field/FieldContainer.js +62 -0
  5. package/Field/index.js +15 -328
  6. package/Field/utils.js +146 -0
  7. package/FormBuilder.js +12 -12
  8. package/Questions/__snapshots__/index.spec.tsx.snap +461 -2499
  9. package/es/Field/FieldBase.js +93 -0
  10. package/es/Field/FieldConditional.js +54 -0
  11. package/es/Field/FieldContainer.js +40 -0
  12. package/es/Field/index.js +11 -308
  13. package/es/Field/utils.js +122 -0
  14. package/es/FormBuilder.js +11 -11
  15. package/es/Questions/__snapshots__/index.spec.tsx.snap +461 -2499
  16. package/es/internal.js +2 -0
  17. package/es/utils.js +5 -3
  18. package/es/validators/index.js +155 -0
  19. package/es/validators/types.js +1 -0
  20. package/es/validators/utils/afm.js +35 -0
  21. package/es/validators/utils/file.js +52 -0
  22. package/es/validators/utils/iban.js +123 -0
  23. package/es/validators/utils/index.js +105 -0
  24. package/es/validators/utils/phone.js +122 -0
  25. package/es/validators/utils/postal_code.js +29 -0
  26. package/es/validators/utils/uuid4.js +20 -0
  27. package/es/{validators.spec.js → validators/validators.spec.js} +1 -1
  28. package/esm/Field/FieldBase.js +93 -0
  29. package/esm/Field/FieldConditional.js +54 -0
  30. package/esm/Field/FieldContainer.js +40 -0
  31. package/esm/Field/index.js +11 -308
  32. package/esm/Field/utils.js +122 -0
  33. package/esm/FormBuilder.js +11 -11
  34. package/esm/Questions/__snapshots__/index.spec.tsx.snap +461 -2499
  35. package/esm/index.js +1 -1
  36. package/esm/internal.js +2 -0
  37. package/esm/utils.js +5 -3
  38. package/esm/validators/index.js +155 -0
  39. package/esm/validators/types.js +1 -0
  40. package/esm/validators/utils/afm.js +35 -0
  41. package/esm/validators/utils/file.js +52 -0
  42. package/esm/validators/utils/iban.js +123 -0
  43. package/esm/validators/utils/index.js +105 -0
  44. package/esm/validators/utils/phone.js +122 -0
  45. package/esm/validators/utils/postal_code.js +29 -0
  46. package/esm/validators/utils/uuid4.js +20 -0
  47. package/esm/{validators.spec.js → validators/validators.spec.js} +1 -1
  48. package/internal.js +21 -0
  49. package/libs/form/src/Field/FieldBase.d.ts +3 -0
  50. package/libs/form/src/Field/FieldConditional.d.ts +4 -0
  51. package/libs/form/src/Field/FieldContainer.d.ts +4 -0
  52. package/libs/form/src/Field/index.d.ts +1 -3
  53. package/libs/form/src/Field/types.d.ts +2 -2
  54. package/libs/form/src/Field/utils.d.ts +5 -0
  55. package/libs/form/src/FormContext.d.ts +2 -2
  56. package/libs/form/src/internal.d.ts +2 -0
  57. package/libs/form/src/types.d.ts +3 -2
  58. package/libs/form/src/validators/index.d.ts +8 -0
  59. package/libs/form/src/validators/types.d.ts +2 -0
  60. package/libs/form/src/validators/utils/afm.d.ts +6 -0
  61. package/libs/form/src/validators/utils/file.d.ts +1 -0
  62. package/libs/form/src/validators/utils/iban.d.ts +2 -0
  63. package/libs/form/src/validators/utils/index.d.ts +12 -0
  64. package/libs/form/src/validators/utils/phone.d.ts +9 -0
  65. package/libs/form/src/validators/utils/postal_code.d.ts +2 -0
  66. package/libs/form/src/validators/utils/uuid4.d.ts +6 -0
  67. package/libs/form/src/{validators.spec.d.ts → validators/validators.spec.d.ts} +0 -0
  68. package/libs/ui/src/core/Button/BackButton.d.ts +1 -1
  69. package/libs/ui/src/core/Button/ButtonLink.d.ts +1 -1
  70. package/libs/ui/src/core/Button/index.d.ts +1 -1
  71. package/libs/ui/src/core/NavList/NavListItem.d.ts +1 -0
  72. package/libs/ui/src/core/NavList/NavListItemBase.d.ts +1 -0
  73. package/libs/ui/src/core/NavList/types.d.ts +1 -0
  74. package/libs-ui/react-core/src/AccordionSectionSummary/index.d.ts +2 -1
  75. package/libs-ui/react-core/src/BackLink/index.d.ts +1 -1
  76. package/libs-ui/react-core/src/Button/index.d.ts +1 -1
  77. package/libs-ui/react-core/src/ButtonLink/index.d.ts +1 -1
  78. package/libs-ui/react-core/src/CallToAction/index.d.ts +1 -1
  79. package/libs-ui/react-core/src/CheckboxItem/index.d.ts +1 -1
  80. package/libs-ui/react-core/src/DateInputItem/index.d.ts +1 -1
  81. package/libs-ui/react-core/src/Field/index.d.ts +3 -3
  82. package/libs-ui/react-core/src/FileUpload/index.d.ts +1 -1
  83. package/libs-ui/react-core/src/Form/index.d.ts +11 -0
  84. package/libs-ui/react-core/src/Link/index.d.ts +1 -1
  85. package/libs-ui/react-core/src/NotificationBannerLink/index.d.ts +1 -1
  86. package/libs-ui/react-core/src/RadioItem/index.d.ts +1 -1
  87. package/libs-ui/react-core/src/Select/index.d.ts +1 -1
  88. package/libs-ui/react-core/src/SvgIcon/index.d.ts +1 -1
  89. package/libs-ui/react-core/src/TabsListItem/index.d.ts +1 -1
  90. package/libs-ui/react-core/src/TextArea/index.d.ts +1 -1
  91. package/libs-ui/react-core/src/TextInput/index.d.ts +1 -1
  92. package/package.json +3 -2
  93. package/utils.js +6 -4
  94. package/validators/index.js +181 -0
  95. package/validators/types.js +5 -0
  96. package/validators/utils/afm.js +45 -0
  97. package/validators/utils/file.js +62 -0
  98. package/validators/utils/iban.js +134 -0
  99. package/validators/utils/index.js +210 -0
  100. package/validators/utils/phone.js +144 -0
  101. package/validators/utils/postal_code.js +40 -0
  102. package/validators/utils/uuid4.js +30 -0
  103. package/validators/validators.spec.js +88 -0
  104. package/es/validators.js +0 -626
  105. package/esm/validators.js +0 -626
  106. package/libs/form/src/validators.d.ts +0 -14
  107. package/validators.js +0 -662
  108. package/validators.spec.js +0 -88
@@ -1,88 +0,0 @@
1
- "use strict";
2
-
3
- var _validators = require("@digigov/form/validators");
4
-
5
- it('validates wrong uuid4 for empty value', function () {
6
- expect((0, _validators.validateUUID4)('')).toBe(false);
7
- });
8
- it('validates wrong uuid4 because of length', function () {
9
- expect((0, _validators.validateUUID4)('9e463bc44a294bab8ee23af6cc3cbbe3')).toBe(false);
10
- });
11
- it('validates wrong uuid4 with correct length and wrong form', function () {
12
- expect((0, _validators.validateUUID4)('ab123cd1-1234-ad34-ad45-12345abcdefg')).toBe(false);
13
- });
14
- it('validates correct uuid4 validator', function () {
15
- expect((0, _validators.validateUUID4)('9e463bc4-4a29-4bab-8ee2-3af6cc3cbbe3')).toBe(true);
16
- });
17
- it('validates correct gr iban', function () {
18
- expect((0, _validators.validateIban)('GR7801100800000008009825202', 'GR')).toBe(true);
19
- });
20
- it('validates correct iban with spaces and dashes', function () {
21
- expect((0, _validators.validateIban)('GR 7801-1008 0000-0008 0098-25202', 'GR')).toBe(true);
22
- });
23
- it('validates correct foreign iban', function () {
24
- expect((0, _validators.validateIban)('DE75512108001245126199', 'DE')).toBe(true);
25
- });
26
- it('validates wrong iban for empty value', function () {
27
- expect((0, _validators.validateIban)('', '')).toBe(false);
28
- });
29
- it('validates wrong greek iban for wrong length', function () {
30
- expect((0, _validators.validateIban)('GR78011008000000080098252020', 'gr')).toBe(false);
31
- });
32
- it('validates wrong iban for non existing country code', function () {
33
- expect((0, _validators.validateIban)('AAA78011008000000080098252020', 'aaa')).toBe(false);
34
- });
35
- it('validates correct greek iban whithout country code', function () {
36
- expect((0, _validators.validateIban)('7801100800000008009825202', '')).toBe(true);
37
- });
38
- it('validates wrong postal code without country code', function () {
39
- expect((0, _validators.validatePostalCode)('123', [])).toBe(true);
40
- });
41
- it('validates wrong postal code with wrong country code', function () {
42
- expect((0, _validators.validatePostalCode)('123', ['FR'])).toBe(true);
43
- });
44
- it('validates wrong postal code with greek country code', function () {
45
- expect((0, _validators.validatePostalCode)('123', ['GR'])).toBe(false);
46
- });
47
- it('validates postal code with greek country code', function () {
48
- expect((0, _validators.validatePostalCode)('11143', ['GR'])).toBe(true);
49
- });
50
- it('validates phone number type landline with greek country code', function () {
51
- expect((0, _validators.validatePhoneNumber)('2102934896', ['GR'], 'landline')).toBe(true);
52
- });
53
- it('validates phone number type landline with ch country code', function () {
54
- expect((0, _validators.validatePhoneNumber)('2102934896', ['CH'], 'landline')).toBe(false);
55
- });
56
- it('validates phone number type landline with ch and gr countries code', function () {
57
- expect((0, _validators.validatePhoneNumber)('2102934896', ['GR', 'CH'], 'landline')).toBe(true);
58
- });
59
- it('validatesphone number type landline with ch and gr countries code', function () {
60
- expect((0, _validators.validatePhoneNumber)('41446681800', ['GR', 'CH'], 'landline')).toBe(true);
61
- });
62
- it('validates phone number type landline with ch and gr countries code but phone number is mobile', function () {
63
- expect((0, _validators.validatePhoneNumber)('2102934896', ['GR', 'CH'], 'mobile')).toBe(false);
64
- });
65
- it('validates phone number type mobile with ch and gr countries code', function () {
66
- expect((0, _validators.validatePhoneNumber)('6934100982', ['GR', 'CH'], 'mobile')).toBe(true);
67
- });
68
- it('validates phone number type mobile with gr country code', function () {
69
- expect((0, _validators.validatePhoneNumber)('6934100982', ['GR'], 'mobile')).toBe(true);
70
- });
71
- it('validates phone number type mobile with ch country code', function () {
72
- expect((0, _validators.validatePhoneNumber)('6934100982', ['CH'], 'mobile')).toBe(false);
73
- });
74
- it('validates phone number with no type and ch country code', function () {
75
- expect((0, _validators.validatePhoneNumber)('6934100982', ['CH'], null)).toBe(false);
76
- });
77
- it('validates phone number with no type and gr country code', function () {
78
- expect((0, _validators.validatePhoneNumber)('6934100982', ['gr'], null)).toBe(true);
79
- });
80
- it('validates phone number with no type and ch country code', function () {
81
- expect((0, _validators.validatePhoneNumber)('41446681800', ['CH'], null)).toBe(true);
82
- });
83
- it('validates phone number with no type and gr country code', function () {
84
- expect((0, _validators.validatePhoneNumber)('41446681800', ['gr'], null)).toBe(false);
85
- });
86
- it('validates phone number with no type and gr and ch countries code', function () {
87
- expect((0, _validators.validatePhoneNumber)('41446681800', ['gr', 'ch'], null)).toBe(true);
88
- });