@digigov/form 2.0.0-750aec28 → 2.0.0-76ec20a0

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 (143) hide show
  1. package/Field/types.d.ts +1 -1
  2. package/FieldArray/__stories__/Default.d.ts +1 -1
  3. package/FieldArray/__stories__/WithExactLength.d.ts +1 -1
  4. package/FieldArray/__stories__/WithModal.d.ts +1 -1
  5. package/FormBuilder/FormBuilder.stories.d.ts +2 -0
  6. package/FormBuilder/__stories__/AutoErrorGrouping.d.ts +1 -1
  7. package/FormBuilder/__stories__/Default.d.ts +1 -1
  8. package/FormBuilder/__stories__/ErrorGrouping.d.ts +1 -1
  9. package/MultiplicityField/MultiplicityField.stories.d.ts +2 -0
  10. package/MultiplicityField/__stories__/Default.d.ts +1 -1
  11. package/MultiplicityField/__stories__/PreviewDisplay.d.ts +1 -1
  12. package/MultiplicityField/__stories__/WithExactLength.d.ts +1 -1
  13. package/MultiplicityField/__stories__/WithMaxLength.d.ts +1 -1
  14. package/MultiplicityField/__stories__/WithMinAndMaxLength.d.ts +1 -1
  15. package/MultiplicityField/__stories__/WithMinLength.d.ts +1 -1
  16. package/Questions/Questions.stories.d.ts +2 -0
  17. package/Questions/__stories__/Default.d.ts +1 -1
  18. package/cjs/Field/types.js.map +1 -1
  19. package/cjs/lazy/index.js +1 -2
  20. package/cjs/lazy.js.map +2 -2
  21. package/cjs/registry/index.js +4 -6
  22. package/cjs/registry.js.map +2 -2
  23. package/cjs/validators/index.js +0 -1
  24. package/cjs/validators/index.js.map +2 -2
  25. package/cjs/validators/utils/index.js +0 -2
  26. package/cjs/validators/utils/index.js.map +2 -2
  27. package/index.js +1 -1
  28. package/inputs/AutoCompleteInput/AutoComplete.stories.d.ts +2 -0
  29. package/inputs/AutoCompleteInput/__stories__/Default.d.ts +1 -1
  30. package/inputs/AutoCompleteInput/__stories__/Multiple.d.ts +1 -1
  31. package/inputs/Checkboxes/Checkboxes.stories.d.ts +2 -0
  32. package/inputs/Checkboxes/__stories__/Conditional.d.ts +1 -1
  33. package/inputs/Checkboxes/__stories__/Default.d.ts +1 -1
  34. package/inputs/Checkboxes/__stories__/WithDivider.d.ts +1 -1
  35. package/inputs/DateInput/DateInput.stories.d.ts +2 -0
  36. package/inputs/DateInput/__stories__/Default.d.ts +1 -1
  37. package/inputs/DateTimeInput/DateTimeInput.stories.d.ts +2 -0
  38. package/inputs/DateTimeInput/__stories__/Default.d.ts +1 -1
  39. package/inputs/FileInput/FileInput.stories.d.ts +2 -0
  40. package/inputs/FileInput/__stories__/Default.d.ts +1 -1
  41. package/inputs/ImageInput/ImageInput.stories.d.ts +2 -0
  42. package/inputs/ImageInput/__stories__/Default.d.ts +1 -1
  43. package/inputs/ImageInput/__stories__/MaxSize.d.ts +1 -1
  44. package/inputs/ImageInput/__stories__/WithInvalidImageDimension.d.ts +1 -1
  45. package/inputs/Input/Input.stories.d.ts +2 -1
  46. package/inputs/Input/__stories__/AFM.d.ts +1 -1
  47. package/inputs/Input/__stories__/Boolean.d.ts +1 -1
  48. package/inputs/Input/__stories__/IBAN.d.ts +1 -1
  49. package/inputs/Input/__stories__/Integer.d.ts +1 -1
  50. package/inputs/Input/__stories__/LandlineNumber.d.ts +1 -1
  51. package/inputs/Input/__stories__/MobilePhone.d.ts +1 -1
  52. package/inputs/Input/__stories__/PhoneNumber.d.ts +1 -1
  53. package/inputs/Input/__stories__/PostalCode.d.ts +1 -1
  54. package/inputs/Input/__stories__/String.d.ts +1 -1
  55. package/inputs/Input/__stories__/StringWithTrimValidation.d.ts +1 -1
  56. package/inputs/Input/__stories__/TextWithLimit.d.ts +1 -1
  57. package/inputs/Label/Label.stories.d.ts +2 -0
  58. package/inputs/Label/__stories__/Default.d.ts +1 -1
  59. package/inputs/OtpInput/OtpInput.stories.d.ts +2 -0
  60. package/inputs/OtpInput/__stories__/Default.d.ts +1 -1
  61. package/inputs/Radio/Radio.stories.d.ts +2 -0
  62. package/inputs/Radio/__stories__/Conditional.d.ts +1 -1
  63. package/inputs/Radio/__stories__/Default.d.ts +1 -1
  64. package/inputs/Radio/__stories__/WithDivider.d.ts +1 -1
  65. package/inputs/Select/Select.stories.d.ts +2 -0
  66. package/inputs/Select/__stories__/Default.d.ts +1 -1
  67. package/lazy/index.js +1 -2
  68. package/package.json +4 -4
  69. package/registry/index.js +4 -6
  70. package/src/Field/types.tsx +0 -1
  71. package/src/FieldArray/__stories__/Default.tsx +1 -1
  72. package/src/FieldArray/__stories__/WithExactLength.tsx +1 -1
  73. package/src/FieldArray/__stories__/WithModal.tsx +1 -1
  74. package/src/FormBuilder/FormBuilder.stories.js +3 -0
  75. package/src/FormBuilder/__stories__/AutoErrorGrouping.tsx +1 -1
  76. package/src/FormBuilder/__stories__/Default.tsx +1 -1
  77. package/src/FormBuilder/__stories__/ErrorGrouping.tsx +1 -1
  78. package/src/MultiplicityField/MultiplicityField.stories.js +3 -0
  79. package/src/MultiplicityField/__stories__/Default.tsx +1 -1
  80. package/src/MultiplicityField/__stories__/PreviewDisplay.tsx +1 -1
  81. package/src/MultiplicityField/__stories__/WithExactLength.tsx +1 -1
  82. package/src/MultiplicityField/__stories__/WithMaxLength.tsx +1 -1
  83. package/src/MultiplicityField/__stories__/WithMinAndMaxLength.tsx +1 -1
  84. package/src/MultiplicityField/__stories__/WithMinLength.tsx +1 -1
  85. package/src/Questions/Questions.stories.js +3 -0
  86. package/src/Questions/__stories__/Default.tsx +1 -1
  87. package/src/inputs/AutoCompleteInput/AutoComplete.stories.js +3 -0
  88. package/src/inputs/AutoCompleteInput/__stories__/Default.tsx +1 -1
  89. package/src/inputs/AutoCompleteInput/__stories__/Multiple.tsx +1 -1
  90. package/src/inputs/Checkboxes/Checkboxes.stories.js +3 -0
  91. package/src/inputs/Checkboxes/__stories__/Conditional.tsx +1 -1
  92. package/src/inputs/Checkboxes/__stories__/Default.tsx +1 -1
  93. package/src/inputs/Checkboxes/__stories__/WithDivider.tsx +1 -1
  94. package/src/inputs/DateInput/DateInput.stories.js +3 -0
  95. package/src/inputs/DateInput/__stories__/Default.tsx +1 -1
  96. package/src/inputs/DateTimeInput/DateTimeInput.stories.js +3 -0
  97. package/src/inputs/DateTimeInput/__stories__/Default.tsx +1 -1
  98. package/src/inputs/FileInput/FileInput.stories.js +3 -0
  99. package/src/inputs/FileInput/__stories__/Default.tsx +1 -1
  100. package/src/inputs/ImageInput/ImageInput.stories.js +3 -0
  101. package/src/inputs/ImageInput/__stories__/Default.tsx +1 -1
  102. package/src/inputs/ImageInput/__stories__/MaxSize.tsx +1 -1
  103. package/src/inputs/ImageInput/__stories__/WithInvalidImageDimension.tsx +1 -1
  104. package/src/inputs/Input/Input.stories.js +3 -1
  105. package/src/inputs/Input/__stories__/AFM.tsx +1 -1
  106. package/src/inputs/Input/__stories__/Boolean.tsx +1 -1
  107. package/src/inputs/Input/__stories__/IBAN.tsx +1 -1
  108. package/src/inputs/Input/__stories__/Integer.tsx +1 -1
  109. package/src/inputs/Input/__stories__/LandlineNumber.tsx +1 -1
  110. package/src/inputs/Input/__stories__/MobilePhone.tsx +1 -1
  111. package/src/inputs/Input/__stories__/PhoneNumber.tsx +1 -1
  112. package/src/inputs/Input/__stories__/PostalCode.tsx +1 -1
  113. package/src/inputs/Input/__stories__/String.tsx +1 -1
  114. package/src/inputs/Input/__stories__/StringWithTrimValidation.tsx +1 -1
  115. package/src/inputs/Input/__stories__/TextWithLimit.tsx +1 -1
  116. package/src/inputs/Label/Label.stories.js +3 -0
  117. package/src/inputs/Label/__stories__/Default.tsx +1 -1
  118. package/src/inputs/OtpInput/OtpInput.stories.js +3 -0
  119. package/src/inputs/OtpInput/__stories__/Default.tsx +1 -1
  120. package/src/inputs/Radio/Radio.stories.js +3 -0
  121. package/src/inputs/Radio/__stories__/Conditional.tsx +1 -1
  122. package/src/inputs/Radio/__stories__/Default.tsx +1 -1
  123. package/src/inputs/Radio/__stories__/WithDivider.tsx +1 -1
  124. package/src/inputs/Select/Select.stories.js +3 -0
  125. package/src/inputs/Select/__stories__/Default.tsx +1 -1
  126. package/src/lazy.js +1 -2
  127. package/src/registry.js +4 -6
  128. package/src/validators/index.ts +0 -5
  129. package/src/validators/utils/index.ts +0 -1
  130. package/validators/index.js +0 -2
  131. package/validators/index.js.map +2 -2
  132. package/validators/utils/index.d.ts +0 -1
  133. package/validators/utils/index.js +0 -1
  134. package/validators/utils/index.js.map +2 -2
  135. package/cjs/validators/utils/amka/index.js +0 -60
  136. package/cjs/validators/utils/amka.js.map +0 -7
  137. package/inputs/Input/__stories__/AMKA.d.ts +0 -3
  138. package/src/inputs/Input/__stories__/AMKA.tsx +0 -23
  139. package/src/validators/utils/amka.ts +0 -39
  140. package/validators/utils/amka/index.js +0 -36
  141. package/validators/utils/amka/package.json +0 -6
  142. package/validators/utils/amka.d.ts +0 -6
  143. package/validators/utils/amka.js.map +0 -7
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../src/validators/utils/index.ts"],
4
- "sourcesContent": ["import * as yup from 'yup';\nimport { FieldSpec } from '@digigov/form/types';\nimport { ValidatorSchema } from '@digigov/form/validators/types';\n\nexport * from '@digigov/form/validators/utils/afm';\nexport * from '@digigov/form/validators/utils/amka';\nexport * from '@digigov/form/validators/utils/file';\nexport * from '@digigov/form/validators/utils/iban';\nexport * from '@digigov/form/validators/utils/otp';\nexport * from '@digigov/form/validators/utils/image';\nexport * from '@digigov/form/validators/utils/phone';\nexport * from '@digigov/form/validators/utils/postal_code';\nexport * from '@digigov/form/validators/utils/uuid4';\nexport * from '@digigov/form/validators/utils/text_limit';\nexport * from '@digigov/form/validators/utils/date';\nexport * from '@digigov/form/validators/utils/datetime';\n\nexport function getYupField(field: FieldSpec, yupTypeMap: Record<string, any>) {\n const yupField = yupTypeMap[field?.type || 'string'] || yupTypeMap['string'];\n return yupField(field);\n}\nexport function computeShape(\n fields: FieldSpec[],\n yupTypeMap: Record<string, ValidatorSchema>,\n validatorRegistry: Record<string, ValidatorSchema[]> | undefined\n) {\n const fieldSchemas = {};\n const objectFields: Record<string, FieldSpec[]> = {};\n fields.forEach((field) => {\n let yupField = getYupField(field, yupTypeMap);\n if (field.condition) {\n for (const key in field.condition) {\n let then: any, otherwise: any;\n if (field.condition[key].then) {\n if (field.condition[key].then?.required === false) {\n then = yupField.nullable();\n } else if (field.condition[key].then?.required === true) {\n then = yupField.nullable().required('form.error.required');\n }\n }\n if (field.condition[key].else) {\n if (field.condition[key].else?.required === false) {\n otherwise = yupField.nullable();\n } else if (field.condition[key].else?.required === true) {\n otherwise = yupField.nullable().required('form.error.required');\n }\n }\n if (then || otherwise) {\n yupField = yupField.when(key, {\n is: (val) => {\n //@ts-ignore\n const is = field.condition[key].is;\n if (is === val || (Array.isArray(val) && val.includes(is))) {\n return true;\n } else {\n return false;\n }\n },\n then,\n otherwise,\n });\n }\n }\n } else if (field.required) {\n yupField = yupField.nullable().required('form.error.required');\n }\n if (validatorRegistry && field.type && validatorRegistry[field.type]) {\n validatorRegistry[field.type].forEach((validator: any) => {\n yupField = yupField.test(validator);\n });\n }\n if (field.validators) {\n field.validators.forEach((validator) => {\n yupField = yupField.test(validator);\n });\n }\n fieldSchemas[field.key] = yupField;\n });\n for (const objectKey in objectFields) {\n fieldSchemas[objectKey] = getYupObjectShape(\n objectFields[objectKey],\n yupTypeMap,\n validatorRegistry\n );\n }\n return fieldSchemas;\n}\n\nexport function getYupObjectShape(\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n fields: FieldSpec[] | any,\n yupTypeMap: Record<string, any>,\n validatorRegistry?: Record<string, ValidatorSchema[]>\n) {\n if (!fields.current) {\n const fieldSchemas = computeShape(fields, yupTypeMap, validatorRegistry);\n return yup.object().shape(fieldSchemas);\n }\n\n return yup.lazy(function () {\n const fieldSchemas = computeShape(\n Object.values(fields.current),\n yupTypeMap,\n validatorRegistry\n );\n return yup.object().shape(fieldSchemas);\n });\n}\n"],
5
- "mappings": "AAAA,YAAY,SAAS;AAIrB,cAAc;AACd,cA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YACF;AAAA,YACA;AAAA,YACA;AAAA,UACF,CAAC;AAAA,QACH;AAAA,MACF;AAAA,IACF,WAAW,MAAM,UAAU;AACzB,iBAAW,SAAS,SAAS,EAAE,SAAS,qBAAqB;AAAA,IAC/D;AACA,QAAI,qBAAqB,MAAM,QAAQ,kBAAkB,MAAM,IAAI,GAAG;AACpE,wBAAkB,MAAM,IAAI,EAAE,QAAQ,CAAC,cAAmB;AACxD,mBAAW,SAAS,KAAK,SAAS;AAAA,MACpC,CAAC;AAAA,IACH;AACA,QAAI,MAAM,YAAY;AACpB,YAAM,WAAW,QAAQ,CAAC,cAAc;AACtC,mBAAW,SAAS,KAAK,SAAS;AAAA,MACpC,CAAC;AAAA,IACH;AACA,iBAAa,MAAM,GAAG,IAAI;AAAA,EAC5B,CAAC;AACD,aAAW,aAAa,cAAc;AACpC,iBAAa,SAAS,IAAI;AAAA,MACxB,aAAa,SAAS;AAAA,MACtB;AAAA,MACA;AAAA,IACF;AAAA,EACF;AACA,SAAO;AACT;AAEO,SAAS,kBAEd,QACA,YACA,mBACA;AACA,MAAI,CAAC,OAAO,SAAS;AACnB,UAAM,eAAe,aAAa,QAAQ,YAAY,iBAAiB;AACvE,WAAO,IAAI,OAAO,EAAE,MAAM,YAAY;AAAA,EACxC;AAEA,SAAO,IAAI,KAAK,WAAY;AAC1B,UAAM,eAAe;AAAA,MACnB,OAAO,OAAO,OAAO,OAAO;AAAA,MAC5B;AAAA,MACA;AAAA,IACF;AACA,WAAO,IAAI,OAAO,EAAE,MAAM,YAAY;AAAA,EACxC,CAAC;AACH;",
4
+ "sourcesContent": ["import * as yup from 'yup';\nimport { FieldSpec } from '@digigov/form/types';\nimport { ValidatorSchema } from '@digigov/form/validators/types';\n\nexport * from '@digigov/form/validators/utils/afm';\nexport * from '@digigov/form/validators/utils/file';\nexport * from '@digigov/form/validators/utils/iban';\nexport * from '@digigov/form/validators/utils/otp';\nexport * from '@digigov/form/validators/utils/image';\nexport * from '@digigov/form/validators/utils/phone';\nexport * from '@digigov/form/validators/utils/postal_code';\nexport * from '@digigov/form/validators/utils/uuid4';\nexport * from '@digigov/form/validators/utils/text_limit';\nexport * from '@digigov/form/validators/utils/date';\nexport * from '@digigov/form/validators/utils/datetime';\n\nexport function getYupField(field: FieldSpec, yupTypeMap: Record<string, any>) {\n const yupField = yupTypeMap[field?.type || 'string'] || yupTypeMap['string'];\n return yupField(field);\n}\nexport function computeShape(\n fields: FieldSpec[],\n yupTypeMap: Record<string, ValidatorSchema>,\n validatorRegistry: Record<string, ValidatorSchema[]> | undefined\n) {\n const fieldSchemas = {};\n const objectFields: Record<string, FieldSpec[]> = {};\n fields.forEach((field) => {\n let yupField = getYupField(field, yupTypeMap);\n if (field.condition) {\n for (const key in field.condition) {\n let then: any, otherwise: any;\n if (field.condition[key].then) {\n if (field.condition[key].then?.required === false) {\n then = yupField.nullable();\n } else if (field.condition[key].then?.required === true) {\n then = yupField.nullable().required('form.error.required');\n }\n }\n if (field.condition[key].else) {\n if (field.condition[key].else?.required === false) {\n otherwise = yupField.nullable();\n } else if (field.condition[key].else?.required === true) {\n otherwise = yupField.nullable().required('form.error.required');\n }\n }\n if (then || otherwise) {\n yupField = yupField.when(key, {\n is: (val) => {\n //@ts-ignore\n const is = field.condition[key].is;\n if (is === val || (Array.isArray(val) && val.includes(is))) {\n return true;\n } else {\n return false;\n }\n },\n then,\n otherwise,\n });\n }\n }\n } else if (field.required) {\n yupField = yupField.nullable().required('form.error.required');\n }\n if (validatorRegistry && field.type && validatorRegistry[field.type]) {\n validatorRegistry[field.type].forEach((validator: any) => {\n yupField = yupField.test(validator);\n });\n }\n if (field.validators) {\n field.validators.forEach((validator) => {\n yupField = yupField.test(validator);\n });\n }\n fieldSchemas[field.key] = yupField;\n });\n for (const objectKey in objectFields) {\n fieldSchemas[objectKey] = getYupObjectShape(\n objectFields[objectKey],\n yupTypeMap,\n validatorRegistry\n );\n }\n return fieldSchemas;\n}\n\nexport function getYupObjectShape(\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n fields: FieldSpec[] | any,\n yupTypeMap: Record<string, any>,\n validatorRegistry?: Record<string, ValidatorSchema[]>\n) {\n if (!fields.current) {\n const fieldSchemas = computeShape(fields, yupTypeMap, validatorRegistry);\n return yup.object().shape(fieldSchemas);\n }\n\n return yup.lazy(function () {\n const fieldSchemas = computeShape(\n Object.values(fields.current),\n yupTypeMap,\n validatorRegistry\n );\n return yup.object().shape(fieldSchemas);\n });\n}\n"],
5
+ "mappings": "AAAA,YAAY,SAAS;AAIrB,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AAEP,SAAS,YAAY,OAAkB,YAAiC;AAC7E,QAAM,WAAW,WAAW,OAAO,QAAQ,QAAQ,KAAK,WAAW,QAAQ;AAC3E,SAAO,SAAS,KAAK;AACvB;AACO,SAAS,aACd,QACA,YACA,mBACA;AACA,QAAM,eAAe,CAAC;AACtB,QAAM,eAA4C,CAAC;AACnD,SAAO,QAAQ,CAAC,UAAU;AACxB,QAAI,WAAW,YAAY,OAAO,UAAU;AAC5C,QAAI,MAAM,WAAW;AACnB,iBAAW,OAAO,MAAM,WAAW;AACjC,YAAI,MAAW;AACf,YAAI,MAAM,UAAU,GAAG,EAAE,MAAM;AAC7B,cAAI,MAAM,UAAU,GAAG,EAAE,MAAM,aAAa,OAAO;AACjD,mBAAO,SAAS,SAAS;AAAA,UAC3B,WAAW,MAAM,UAAU,GAAG,EAAE,MAAM,aAAa,MAAM;AACvD,mBAAO,SAAS,SAAS,EAAE,SAAS,qBAAqB;AAAA,UAC3D;AAAA,QACF;AACA,YAAI,MAAM,UAAU,GAAG,EAAE,MAAM;AAC7B,cAAI,MAAM,UAAU,GAAG,EAAE,MAAM,aAAa,OAAO;AACjD,wBAAY,SAAS,SAAS;AAAA,UAChC,WAAW,MAAM,UAAU,GAAG,EAAE,MAAM,aAAa,MAAM;AACv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AAAA,IACF;AACA,WAAO,IAAI,OAAO,EAAE,MAAM,YAAY;AAAA,EACxC,CAAC;AACH;",
6
6
  "names": []
7
7
  }
@@ -1,60 +0,0 @@
1
- var __defProp = Object.defineProperty;
2
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
3
- var __getOwnPropNames = Object.getOwnPropertyNames;
4
- var __hasOwnProp = Object.prototype.hasOwnProperty;
5
- var __export = (target, all) => {
6
- for (var name in all)
7
- __defProp(target, name, { get: all[name], enumerable: true });
8
- };
9
- var __copyProps = (to, from, except, desc) => {
10
- if (from && typeof from === "object" || typeof from === "function") {
11
- for (let key of __getOwnPropNames(from))
12
- if (!__hasOwnProp.call(to, key) && key !== except)
13
- __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
14
- }
15
- return to;
16
- };
17
- var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
18
- var amka_exports = {};
19
- __export(amka_exports, {
20
- AMKA_VALIDATOR: () => AMKA_VALIDATOR,
21
- validateAMKA: () => validateAMKA
22
- });
23
- module.exports = __toCommonJS(amka_exports);
24
- function digitSum(number) {
25
- const sum = number > 9 ? 1 : 0;
26
- return sum + number % 10;
27
- }
28
- function validateAMKA(amka) {
29
- amka = String(amka);
30
- const checkDigitIndex = amka.length - 1;
31
- let sum = 0;
32
- amka.substring(0, checkDigitIndex).split("").reverse().forEach(function(value, index) {
33
- const weight = (index + 1) % 2 + 1;
34
- sum += digitSum(parseInt(value, 10) * weight);
35
- });
36
- const sumMod10 = sum % 10;
37
- if (sumMod10 === 0) {
38
- return amka.substring(checkDigitIndex) === "0";
39
- } else {
40
- return amka.substring(checkDigitIndex) === 10 - sumMod10 + "";
41
- }
42
- }
43
- const AMKA_VALIDATOR = {
44
- name: "amka-validator",
45
- message: "form.error.amka",
46
- test: (value) => {
47
- if (!value) return true;
48
- const AMKA_REGEX = /^[0-9]{11}$/;
49
- if (!AMKA_REGEX.test(value) || value === "00000000000") {
50
- return false;
51
- }
52
- return validateAMKA(value);
53
- }
54
- };
55
- // Annotate the CommonJS export names for ESM import in node:
56
- 0 && (module.exports = {
57
- AMKA_VALIDATOR,
58
- validateAMKA
59
- });
60
- //# sourceMappingURL=amka.js.map
@@ -1,7 +0,0 @@
1
- {
2
- "version": 3,
3
- "sources": ["../../../../src/validators/utils/amka.ts"],
4
- "sourcesContent": ["function digitSum(number) {\n const sum = number > 9 ? 1 : 0;\n return sum + (number % 10);\n}\n\nexport function validateAMKA(amka: string): boolean {\n // Validate that the last digit is the correct check digit (created using the\n // Luhn algorithm https://en.wikipedia.org/wiki/Luhn_algorithm).\n amka = String(amka);\n const checkDigitIndex = amka.length - 1;\n let sum = 0;\n amka\n .substring(0, checkDigitIndex)\n .split('')\n .reverse()\n .forEach(function (value, index) {\n const weight = ((index + 1) % 2) + 1;\n sum += digitSum(parseInt(value, 10) * weight);\n });\n const sumMod10 = sum % 10;\n if (sumMod10 === 0) {\n return amka.substring(checkDigitIndex) === '0';\n } else {\n return amka.substring(checkDigitIndex) === 10 - sumMod10 + '';\n }\n}\n\nexport const AMKA_VALIDATOR = {\n name: 'amka-validator',\n message: 'form.error.amka',\n test: (value): boolean => {\n if (!value) return true;\n const AMKA_REGEX = /^[0-9]{11}$/;\n if (!AMKA_REGEX.test(value) || value === '00000000000') {\n return false;\n }\n return validateAMKA(value);\n },\n};\n"],
5
- "mappings": ";;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,SAAS,SAAS,QAAQ;AACxB,QAAM,MAAM,SAAS,IAAI,IAAI;AAC7B,SAAO,MAAO,SAAS;AACzB;AAEO,SAAS,aAAa,MAAuB;AAGlD,SAAO,OAAO,IAAI;AAClB,QAAM,kBAAkB,KAAK,SAAS;AACtC,MAAI,MAAM;AACV,OACG,UAAU,GAAG,eAAe,EAC5B,MAAM,EAAE,EACR,QAAQ,EACR,QAAQ,SAAU,OAAO,OAAO;AAC/B,UAAM,UAAW,QAAQ,KAAK,IAAK;AACnC,WAAO,SAAS,SAAS,OAAO,EAAE,IAAI,MAAM;AAAA,EAC9C,CAAC;AACH,QAAM,WAAW,MAAM;AACvB,MAAI,aAAa,GAAG;AAClB,WAAO,KAAK,UAAU,eAAe,MAAM;AAAA,EAC7C,OAAO;AACL,WAAO,KAAK,UAAU,eAAe,MAAM,KAAK,WAAW;AAAA,EAC7D;AACF;AAEO,MAAM,iBAAiB;AAAA,EAC5B,MAAM;AAAA,EACN,SAAS;AAAA,EACT,MAAM,CAAC,UAAmB;AACxB,QAAI,CAAC,MAAO,QAAO;AACnB,UAAM,aAAa;AACnB,QAAI,CAAC,WAAW,KAAK,KAAK,KAAK,UAAU,eAAe;AACtD,aAAO;AAAA,IACT;AACA,WAAO,aAAa,KAAK;AAAA,EAC3B;AACF;",
6
- "names": []
7
- }
@@ -1,3 +0,0 @@
1
- import React from 'react';
2
- export declare const AMKA: () => React.JSX.Element;
3
- export default AMKA;
@@ -1,23 +0,0 @@
1
- import React from 'react';
2
- import FormBuilder, { Field } from '@digigov/form';
3
- import { Button } from '@digigov/ui/form/Button';
4
-
5
- export const AMKA = () => (
6
- <FormBuilder
7
- onSubmit={(data) => {
8
- console.log(data);
9
- }}
10
- >
11
- <Field
12
- key="amka"
13
- name="amka"
14
- type="amka"
15
- label={{
16
- primary: 'Αριθμός μητρώου κοινωνικής ασφάλισης',
17
- }}
18
- required
19
- />
20
- <Button type="submit">Συνέχεια</Button>
21
- </FormBuilder>
22
- );
23
- export default AMKA;
@@ -1,39 +0,0 @@
1
- function digitSum(number) {
2
- const sum = number > 9 ? 1 : 0;
3
- return sum + (number % 10);
4
- }
5
-
6
- export function validateAMKA(amka: string): boolean {
7
- // Validate that the last digit is the correct check digit (created using the
8
- // Luhn algorithm https://en.wikipedia.org/wiki/Luhn_algorithm).
9
- amka = String(amka);
10
- const checkDigitIndex = amka.length - 1;
11
- let sum = 0;
12
- amka
13
- .substring(0, checkDigitIndex)
14
- .split('')
15
- .reverse()
16
- .forEach(function (value, index) {
17
- const weight = ((index + 1) % 2) + 1;
18
- sum += digitSum(parseInt(value, 10) * weight);
19
- });
20
- const sumMod10 = sum % 10;
21
- if (sumMod10 === 0) {
22
- return amka.substring(checkDigitIndex) === '0';
23
- } else {
24
- return amka.substring(checkDigitIndex) === 10 - sumMod10 + '';
25
- }
26
- }
27
-
28
- export const AMKA_VALIDATOR = {
29
- name: 'amka-validator',
30
- message: 'form.error.amka',
31
- test: (value): boolean => {
32
- if (!value) return true;
33
- const AMKA_REGEX = /^[0-9]{11}$/;
34
- if (!AMKA_REGEX.test(value) || value === '00000000000') {
35
- return false;
36
- }
37
- return validateAMKA(value);
38
- },
39
- };
@@ -1,36 +0,0 @@
1
- function digitSum(number) {
2
- const sum = number > 9 ? 1 : 0;
3
- return sum + number % 10;
4
- }
5
- function validateAMKA(amka) {
6
- amka = String(amka);
7
- const checkDigitIndex = amka.length - 1;
8
- let sum = 0;
9
- amka.substring(0, checkDigitIndex).split("").reverse().forEach(function(value, index) {
10
- const weight = (index + 1) % 2 + 1;
11
- sum += digitSum(parseInt(value, 10) * weight);
12
- });
13
- const sumMod10 = sum % 10;
14
- if (sumMod10 === 0) {
15
- return amka.substring(checkDigitIndex) === "0";
16
- } else {
17
- return amka.substring(checkDigitIndex) === 10 - sumMod10 + "";
18
- }
19
- }
20
- const AMKA_VALIDATOR = {
21
- name: "amka-validator",
22
- message: "form.error.amka",
23
- test: (value) => {
24
- if (!value) return true;
25
- const AMKA_REGEX = /^[0-9]{11}$/;
26
- if (!AMKA_REGEX.test(value) || value === "00000000000") {
27
- return false;
28
- }
29
- return validateAMKA(value);
30
- }
31
- };
32
- export {
33
- AMKA_VALIDATOR,
34
- validateAMKA
35
- };
36
- //# sourceMappingURL=amka.js.map
@@ -1,6 +0,0 @@
1
- {
2
- "sideEffects": false,
3
- "module": "./index.js",
4
- "types": "./index.d.ts",
5
- "main": "../../../cjs/validators/utils/amka/index.js"
6
- }
@@ -1,6 +0,0 @@
1
- export declare function validateAMKA(amka: string): boolean;
2
- export declare const AMKA_VALIDATOR: {
3
- name: string;
4
- message: string;
5
- test: (value: any) => boolean;
6
- };
@@ -1,7 +0,0 @@
1
- {
2
- "version": 3,
3
- "sources": ["../../../src/validators/utils/amka.ts"],
4
- "sourcesContent": ["function digitSum(number) {\n const sum = number > 9 ? 1 : 0;\n return sum + (number % 10);\n}\n\nexport function validateAMKA(amka: string): boolean {\n // Validate that the last digit is the correct check digit (created using the\n // Luhn algorithm https://en.wikipedia.org/wiki/Luhn_algorithm).\n amka = String(amka);\n const checkDigitIndex = amka.length - 1;\n let sum = 0;\n amka\n .substring(0, checkDigitIndex)\n .split('')\n .reverse()\n .forEach(function (value, index) {\n const weight = ((index + 1) % 2) + 1;\n sum += digitSum(parseInt(value, 10) * weight);\n });\n const sumMod10 = sum % 10;\n if (sumMod10 === 0) {\n return amka.substring(checkDigitIndex) === '0';\n } else {\n return amka.substring(checkDigitIndex) === 10 - sumMod10 + '';\n }\n}\n\nexport const AMKA_VALIDATOR = {\n name: 'amka-validator',\n message: 'form.error.amka',\n test: (value): boolean => {\n if (!value) return true;\n const AMKA_REGEX = /^[0-9]{11}$/;\n if (!AMKA_REGEX.test(value) || value === '00000000000') {\n return false;\n }\n return validateAMKA(value);\n },\n};\n"],
5
- "mappings": "AAAA,SAAS,SAAS,QAAQ;AACxB,QAAM,MAAM,SAAS,IAAI,IAAI;AAC7B,SAAO,MAAO,SAAS;AACzB;AAEO,SAAS,aAAa,MAAuB;AAGlD,SAAO,OAAO,IAAI;AAClB,QAAM,kBAAkB,KAAK,SAAS;AACtC,MAAI,MAAM;AACV,OACG,UAAU,GAAG,eAAe,EAC5B,MAAM,EAAE,EACR,QAAQ,EACR,QAAQ,SAAU,OAAO,OAAO;AAC/B,UAAM,UAAW,QAAQ,KAAK,IAAK;AACnC,WAAO,SAAS,SAAS,OAAO,EAAE,IAAI,MAAM;AAAA,EAC9C,CAAC;AACH,QAAM,WAAW,MAAM;AACvB,MAAI,aAAa,GAAG;AAClB,WAAO,KAAK,UAAU,eAAe,MAAM;AAAA,EAC7C,OAAO;AACL,WAAO,KAAK,UAAU,eAAe,MAAM,KAAK,WAAW;AAAA,EAC7D;AACF;AAEO,MAAM,iBAAiB;AAAA,EAC5B,MAAM;AAAA,EACN,SAAS;AAAA,EACT,MAAM,CAAC,UAAmB;AACxB,QAAI,CAAC,MAAO,QAAO;AACnB,UAAM,aAAa;AACnB,QAAI,CAAC,WAAW,KAAK,KAAK,KAAK,UAAU,eAAe;AACtD,aAAO;AAAA,IACT;AACA,WAAO,aAAa,KAAK;AAAA,EAC3B;AACF;",
6
- "names": []
7
- }