@webiny/validation 0.0.0-ee-vpcs.549378cf03

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 (87) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +409 -0
  3. package/index.d.ts +4 -0
  4. package/index.js +96 -0
  5. package/index.js.map +1 -0
  6. package/package.json +45 -0
  7. package/types.d.ts +30 -0
  8. package/types.js +5 -0
  9. package/types.js.map +1 -0
  10. package/validation.d.ts +62 -0
  11. package/validation.js +199 -0
  12. package/validation.js.map +1 -0
  13. package/validationError.d.ts +10 -0
  14. package/validationError.js +29 -0
  15. package/validationError.js.map +1 -0
  16. package/validators/creditCard.d.ts +15 -0
  17. package/validators/creditCard.js +69 -0
  18. package/validators/creditCard.js.map +1 -0
  19. package/validators/dateGte.d.ts +5 -0
  20. package/validators/dateGte.js +37 -0
  21. package/validators/dateGte.js.map +1 -0
  22. package/validators/dateLte.d.ts +5 -0
  23. package/validators/dateLte.js +37 -0
  24. package/validators/dateLte.js.map +1 -0
  25. package/validators/email.d.ts +15 -0
  26. package/validators/email.js +41 -0
  27. package/validators/email.js.map +1 -0
  28. package/validators/eq.d.ts +16 -0
  29. package/validators/eq.js +41 -0
  30. package/validators/eq.js.map +1 -0
  31. package/validators/gt.d.ts +16 -0
  32. package/validators/gt.js +38 -0
  33. package/validators/gt.js.map +1 -0
  34. package/validators/gte.d.ts +16 -0
  35. package/validators/gte.js +38 -0
  36. package/validators/gte.js.map +1 -0
  37. package/validators/in.d.ts +2 -0
  38. package/validators/in.js +27 -0
  39. package/validators/in.js.map +1 -0
  40. package/validators/integer.d.ts +2 -0
  41. package/validators/integer.js +26 -0
  42. package/validators/integer.js.map +1 -0
  43. package/validators/json.d.ts +2 -0
  44. package/validators/json.js +24 -0
  45. package/validators/json.js.map +1 -0
  46. package/validators/lt.d.ts +2 -0
  47. package/validators/lt.js +26 -0
  48. package/validators/lt.js.map +1 -0
  49. package/validators/lte.d.ts +2 -0
  50. package/validators/lte.js +26 -0
  51. package/validators/lte.js.map +1 -0
  52. package/validators/maxLength.d.ts +2 -0
  53. package/validators/maxLength.js +44 -0
  54. package/validators/maxLength.js.map +1 -0
  55. package/validators/minLength.d.ts +2 -0
  56. package/validators/minLength.js +44 -0
  57. package/validators/minLength.js.map +1 -0
  58. package/validators/number.d.ts +8 -0
  59. package/validators/number.js +34 -0
  60. package/validators/number.js.map +1 -0
  61. package/validators/numeric.d.ts +8 -0
  62. package/validators/numeric.js +42 -0
  63. package/validators/numeric.js.map +1 -0
  64. package/validators/password.d.ts +2 -0
  65. package/validators/password.js +26 -0
  66. package/validators/password.js.map +1 -0
  67. package/validators/phone.d.ts +2 -0
  68. package/validators/phone.js +26 -0
  69. package/validators/phone.js.map +1 -0
  70. package/validators/required.d.ts +2 -0
  71. package/validators/required.js +22 -0
  72. package/validators/required.js.map +1 -0
  73. package/validators/slug.d.ts +2 -0
  74. package/validators/slug.js +26 -0
  75. package/validators/slug.js.map +1 -0
  76. package/validators/time/index.d.ts +6 -0
  77. package/validators/time/index.js +79 -0
  78. package/validators/time/index.js.map +1 -0
  79. package/validators/timeGte.d.ts +5 -0
  80. package/validators/timeGte.js +38 -0
  81. package/validators/timeGte.js.map +1 -0
  82. package/validators/timeLte.d.ts +5 -0
  83. package/validators/timeLte.js +38 -0
  84. package/validators/timeLte.js.map +1 -0
  85. package/validators/url.d.ts +2 -0
  86. package/validators/url.js +59 -0
  87. package/validators/url.js.map +1 -0
@@ -0,0 +1,26 @@
1
+ "use strict";
2
+
3
+ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
4
+
5
+ Object.defineProperty(exports, "__esModule", {
6
+ value: true
7
+ });
8
+ exports.default = void 0;
9
+
10
+ var _validationError = _interopRequireDefault(require("../validationError"));
11
+
12
+ var _default = value => {
13
+ if (!value) {
14
+ return;
15
+ }
16
+
17
+ value = value + "";
18
+
19
+ if (value.match(/^[a-z0-9]+(-[a-z0-9]+)*$/) && value.length <= 100) {
20
+ return;
21
+ }
22
+
23
+ throw new _validationError.default("Slug must consist of only 'a-z', '0-9' and '-' and be max 100 characters long (for example: 'some-slug' or 'some-slug-2')");
24
+ };
25
+
26
+ exports.default = _default;
@@ -0,0 +1 @@
1
+ {"version":3,"names":["value","match","length","ValidationError"],"sources":["slug.ts"],"sourcesContent":["import ValidationError from \"~/validationError\";\n\nexport default (value: any) => {\n if (!value) {\n return;\n }\n value = value + \"\";\n\n if (value.match(/^[a-z0-9]+(-[a-z0-9]+)*$/) && value.length <= 100) {\n return;\n }\n\n throw new ValidationError(\n \"Slug must consist of only 'a-z', '0-9' and '-' and be max 100 characters long (for example: 'some-slug' or 'some-slug-2')\"\n );\n};\n"],"mappings":";;;;;;;;;AAAA;;eAEgBA,KAAD,IAAgB;EAC3B,IAAI,CAACA,KAAL,EAAY;IACR;EACH;;EACDA,KAAK,GAAGA,KAAK,GAAG,EAAhB;;EAEA,IAAIA,KAAK,CAACC,KAAN,CAAY,0BAAZ,KAA2CD,KAAK,CAACE,MAAN,IAAgB,GAA/D,EAAoE;IAChE;EACH;;EAED,MAAM,IAAIC,wBAAJ,CACF,2HADE,CAAN;AAGH,C"}
@@ -0,0 +1,6 @@
1
+ /**
2
+ * returns 1 if time is greater than compareTo
3
+ * returns 0 if they are equal
4
+ * returns -1 if compareTo is greater than time
5
+ */
6
+ export declare const compareTime: (time: string, compareTo: string) => number;
@@ -0,0 +1,79 @@
1
+ "use strict";
2
+
3
+ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
4
+
5
+ Object.defineProperty(exports, "__esModule", {
6
+ value: true
7
+ });
8
+ exports.compareTime = void 0;
9
+
10
+ var _validationError = _interopRequireDefault(require("../../validationError"));
11
+
12
+ const parseTime = value => {
13
+ const parsed = value.split(":").map(Number);
14
+
15
+ if (parsed.length < 2) {
16
+ throw new _validationError.default(`Value "${value}" does not look like time.`);
17
+ }
18
+
19
+ const [hours, minutes, seconds = 0] = parsed;
20
+
21
+ if (hours >= 24) {
22
+ throw new _validationError.default(`There cannot be more than 24 hours. Value parsed is "${value}".`);
23
+ } else if (hours < 0) {
24
+ throw new _validationError.default(`Hours cannot go into negative. Value parsed is "${value}".`);
25
+ } else if (minutes >= 60) {
26
+ throw new _validationError.default(`There cannot be more than 59 minutes. Value parsed is "${value}".`);
27
+ } else if (minutes < 0) {
28
+ throw new _validationError.default(`Minutes cannot go into negative. Value parsed is "${value}".`);
29
+ } else if (seconds >= 60) {
30
+ throw new _validationError.default(`There cannot be more than 59 seconds. Value parsed is "${value}".`);
31
+ } else if (seconds < 0) {
32
+ throw new _validationError.default(`Seconds cannot go into negative. Value parsed is "${value}".`);
33
+ }
34
+
35
+ return {
36
+ hours,
37
+ minutes,
38
+ seconds
39
+ };
40
+ };
41
+ /**
42
+ * returns 1 if time is greater than compareTo
43
+ * returns 0 if they are equal
44
+ * returns -1 if compareTo is greater than time
45
+ */
46
+
47
+
48
+ const compareTime = (time, compareTo) => {
49
+ const {
50
+ hours: timeHours,
51
+ minutes: timeMinutes,
52
+ seconds: timeSeconds
53
+ } = parseTime(time);
54
+ const {
55
+ hours: compareToHours,
56
+ minutes: compareToMinutes,
57
+ seconds: compareToSeconds
58
+ } = parseTime(compareTo);
59
+
60
+ if (timeHours > compareToHours) {
61
+ return 1;
62
+ }
63
+
64
+ if (timeHours === compareToHours) {
65
+ if (timeMinutes > compareToMinutes) {
66
+ return 1;
67
+ } else if (timeMinutes === compareToMinutes) {
68
+ if (timeSeconds > compareToSeconds) {
69
+ return 1;
70
+ } else if (timeSeconds === compareToSeconds) {
71
+ return 0;
72
+ }
73
+ }
74
+ }
75
+
76
+ return -1;
77
+ };
78
+
79
+ exports.compareTime = compareTime;
@@ -0,0 +1 @@
1
+ {"version":3,"names":["parseTime","value","parsed","split","map","Number","length","ValidationError","hours","minutes","seconds","compareTime","time","compareTo","timeHours","timeMinutes","timeSeconds","compareToHours","compareToMinutes","compareToSeconds"],"sources":["index.ts"],"sourcesContent":["import ValidationError from \"~/validationError\";\n\ninterface ParsedTimeResult {\n hours: number;\n minutes: number;\n seconds: number;\n}\nconst parseTime = (value: string): ParsedTimeResult => {\n const parsed = value.split(\":\").map(Number);\n if (parsed.length < 2) {\n throw new ValidationError(`Value \"${value}\" does not look like time.`);\n }\n const [hours, minutes, seconds = 0] = parsed;\n if (hours >= 24) {\n throw new ValidationError(\n `There cannot be more than 24 hours. Value parsed is \"${value}\".`\n );\n } else if (hours < 0) {\n throw new ValidationError(`Hours cannot go into negative. Value parsed is \"${value}\".`);\n } else if (minutes >= 60) {\n throw new ValidationError(\n `There cannot be more than 59 minutes. Value parsed is \"${value}\".`\n );\n } else if (minutes < 0) {\n throw new ValidationError(`Minutes cannot go into negative. Value parsed is \"${value}\".`);\n } else if (seconds >= 60) {\n throw new ValidationError(\n `There cannot be more than 59 seconds. Value parsed is \"${value}\".`\n );\n } else if (seconds < 0) {\n throw new ValidationError(`Seconds cannot go into negative. Value parsed is \"${value}\".`);\n }\n return {\n hours,\n minutes,\n seconds\n };\n};\n/**\n * returns 1 if time is greater than compareTo\n * returns 0 if they are equal\n * returns -1 if compareTo is greater than time\n */\nexport const compareTime = (time: string, compareTo: string): number => {\n const { hours: timeHours, minutes: timeMinutes, seconds: timeSeconds } = parseTime(time);\n const {\n hours: compareToHours,\n minutes: compareToMinutes,\n seconds: compareToSeconds\n } = parseTime(compareTo);\n if (timeHours > compareToHours) {\n return 1;\n }\n if (timeHours === compareToHours) {\n if (timeMinutes > compareToMinutes) {\n return 1;\n } else if (timeMinutes === compareToMinutes) {\n if (timeSeconds > compareToSeconds) {\n return 1;\n } else if (timeSeconds === compareToSeconds) {\n return 0;\n }\n }\n }\n return -1;\n};\n"],"mappings":";;;;;;;;;AAAA;;AAOA,MAAMA,SAAS,GAAIC,KAAD,IAAqC;EACnD,MAAMC,MAAM,GAAGD,KAAK,CAACE,KAAN,CAAY,GAAZ,EAAiBC,GAAjB,CAAqBC,MAArB,CAAf;;EACA,IAAIH,MAAM,CAAC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a,SAAD,CAJb;;EAKA,IAAIC,SAAS,GAAGG,cAAhB,EAAgC;IAC5B,OAAO,CAAP;EACH;;EACD,IAAIH,SAAS,KAAKG,cAAlB,EAAkC;IAC9B,IAAIF,WAAW,GAAGG,gBAAlB,EAAoC;MAChC,OAAO,CAAP;IACH,CAFD,MAEO,IAAIH,WAAW,KAAKG,gBAApB,EAAsC;MACzC,IAAIF,WAAW,GAAGG,gBAAlB,EAAoC;QAChC,OAAO,CAAP;MACH,CAFD,MAEO,IAAIH,WAAW,KAAKG,gBAApB,EAAsC;QACzC,OAAO,CAAP;MACH;IACJ;EACJ;;EACD,OAAO,CAAC,CAAR;AACH,CAtBM"}
@@ -0,0 +1,5 @@
1
+ /**
2
+ * Validates that given value is a greater or equal to a gteValue
3
+ */
4
+ declare const _default: (value: string, params?: string[]) => void;
5
+ export default _default;
@@ -0,0 +1,38 @@
1
+ "use strict";
2
+
3
+ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
4
+
5
+ Object.defineProperty(exports, "__esModule", {
6
+ value: true
7
+ });
8
+ exports.default = void 0;
9
+
10
+ var _validationError = _interopRequireDefault(require("../validationError"));
11
+
12
+ var _time = require("./time");
13
+
14
+ /**
15
+ * Validates that given value is a greater or equal to a gteValue
16
+ */
17
+ var _default = (value, params) => {
18
+ if (!value || !params) {
19
+ return;
20
+ } // we need to join because validation params are being split by :
21
+
22
+
23
+ const gteValue = params.join(":");
24
+
25
+ if (!gteValue) {
26
+ return;
27
+ }
28
+
29
+ const compare = (0, _time.compareTime)(value, gteValue);
30
+
31
+ if (compare >= 0) {
32
+ return;
33
+ }
34
+
35
+ throw new _validationError.default(`Value needs to be greater than or equal to "${gteValue}".`);
36
+ };
37
+
38
+ exports.default = _default;
@@ -0,0 +1 @@
1
+ {"version":3,"names":["value","params","gteValue","join","compare","compareTime","ValidationError"],"sources":["timeGte.ts"],"sourcesContent":["import ValidationError from \"~/validationError\";\nimport { compareTime } from \"./time\";\n\n/**\n * Validates that given value is a greater or equal to a gteValue\n */\nexport default (value: string, params?: string[]) => {\n if (!value || !params) {\n return;\n }\n // we need to join because validation params are being split by :\n const gteValue = params.join(\":\");\n if (!gteValue) {\n return;\n }\n\n const compare = compareTime(value, gteValue);\n\n if (compare >= 0) {\n return;\n }\n throw new ValidationError(`Value needs to be greater than or equal to \"${gteValue}\".`);\n};\n"],"mappings":";;;;;;;;;AAAA;;AACA;;AAEA;AACA;AACA;eACe,CAACA,KAAD,EAAgBC,MAAhB,KAAsC;EACjD,IAAI,CAACD,KAAD,IAAU,CAACC,MAAf,EAAuB;IACnB;EACH,CAHgD,CAIjD;;;EACA,MAAMC,QAAQ,GAAGD,MAAM,CAACE,IAAP,CAAY,GAAZ,CAAjB;;EACA,IAAI,CAACD,QAAL,EAAe;IACX;EACH;;EAED,MAAME,OAAO,GAAG,IAAAC,iBAAA,EAAYL,KAAZ,EAAmBE,QAAnB,CAAhB;;EAEA,IAAIE,OAAO,IAAI,CAAf,EAAkB;IACd;EACH;;EACD,MAAM,IAAIE,wBAAJ,CAAqB,+CAA8CJ,QAAS,IAA5E,CAAN;AACH,C"}
@@ -0,0 +1,5 @@
1
+ /**
2
+ * Validates that given value is a leaser or equal to a lteValue
3
+ */
4
+ declare const _default: (value: string, params?: string[]) => void;
5
+ export default _default;
@@ -0,0 +1,38 @@
1
+ "use strict";
2
+
3
+ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
4
+
5
+ Object.defineProperty(exports, "__esModule", {
6
+ value: true
7
+ });
8
+ exports.default = void 0;
9
+
10
+ var _validationError = _interopRequireDefault(require("../validationError"));
11
+
12
+ var _time = require("./time");
13
+
14
+ /**
15
+ * Validates that given value is a leaser or equal to a lteValue
16
+ */
17
+ var _default = (value, params) => {
18
+ if (!value || !params) {
19
+ return;
20
+ } // we need to join because validation params are being split by :
21
+
22
+
23
+ const lteValue = params.join(":");
24
+
25
+ if (!lteValue) {
26
+ return;
27
+ }
28
+
29
+ const compare = (0, _time.compareTime)(value, lteValue);
30
+
31
+ if (compare <= 0) {
32
+ return;
33
+ }
34
+
35
+ throw new _validationError.default(`Value needs to be lesser than or equal to "${lteValue}".`);
36
+ };
37
+
38
+ exports.default = _default;
@@ -0,0 +1 @@
1
+ {"version":3,"names":["value","params","lteValue","join","compare","compareTime","ValidationError"],"sources":["timeLte.ts"],"sourcesContent":["import ValidationError from \"~/validationError\";\nimport { compareTime } from \"./time\";\n\n/**\n * Validates that given value is a leaser or equal to a lteValue\n */\nexport default (value: string, params?: string[]) => {\n if (!value || !params) {\n return;\n }\n // we need to join because validation params are being split by :\n const lteValue = params.join(\":\");\n if (!lteValue) {\n return;\n }\n\n const compare = compareTime(value, lteValue);\n if (compare <= 0) {\n return;\n }\n throw new ValidationError(`Value needs to be lesser than or equal to \"${lteValue}\".`);\n};\n"],"mappings":";;;;;;;;;AAAA;;AACA;;AAEA;AACA;AACA;eACe,CAACA,KAAD,EAAgBC,MAAhB,KAAsC;EACjD,IAAI,CAACD,KAAD,IAAU,CAACC,MAAf,EAAuB;IACnB;EACH,CAHgD,CAIjD;;;EACA,MAAMC,QAAQ,GAAGD,MAAM,CAACE,IAAP,CAAY,GAAZ,CAAjB;;EACA,IAAI,CAACD,QAAL,EAAe;IACX;EACH;;EAED,MAAME,OAAO,GAAG,IAAAC,iBAAA,EAAYL,KAAZ,EAAmBE,QAAnB,CAAhB;;EACA,IAAIE,OAAO,IAAI,CAAf,EAAkB;IACd;EACH;;EACD,MAAM,IAAIE,wBAAJ,CAAqB,8CAA6CJ,QAAS,IAA3E,CAAN;AACH,C"}
@@ -0,0 +1,2 @@
1
+ declare const _default: (value: any, params?: string[]) => void;
2
+ export default _default;
@@ -0,0 +1,59 @@
1
+ "use strict";
2
+
3
+ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
4
+
5
+ Object.defineProperty(exports, "__esModule", {
6
+ value: true
7
+ });
8
+ exports.default = void 0;
9
+
10
+ var _validationError = _interopRequireDefault(require("../validationError"));
11
+
12
+ const regex = {
13
+ base: new RegExp( // eslint-disable-next-line
14
+ /^(https?:\/\/)((([a-z\d]([a-z\d-]*[a-z\d])*)\.)+[a-z]{2,}|((\d{1,3}\.){3}\d{1,3}))(\:\d+)?(\/[-a-z\d%_.~+]*)*(\?[;&a-z\d%_.~+=!-]*)?(\#[-a-z\d_]*)?$/i),
15
+ ip: new RegExp( // eslint-disable-next-line
16
+ /^(https?:\/\/)(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)$/),
17
+ relative: new RegExp( // eslint-disable-next-line
18
+ /^\/.*$/),
19
+ href: new RegExp( // eslint-disable-next-line
20
+ /^(#|mailto:|tel:)\S*$/)
21
+ };
22
+
23
+ var _default = (value, params) => {
24
+ if (!value || !params) {
25
+ return;
26
+ }
27
+
28
+ value = value + "";
29
+
30
+ if (value.startsWith("http://localhost") || value.startsWith("https://localhost")) {
31
+ value = value.replace("//localhost", "//localhost.com");
32
+ }
33
+
34
+ if (regex.base.test(value)) {
35
+ if (!params.includes("noIp")) {
36
+ return;
37
+ }
38
+
39
+ if (!regex.ip.test(value)) {
40
+ return;
41
+ }
42
+ }
43
+
44
+ if (params.includes("allowRelative")) {
45
+ if (regex.relative.test(value)) {
46
+ return;
47
+ }
48
+ }
49
+
50
+ if (params.includes("allowHref")) {
51
+ if (regex.href.test(value)) {
52
+ return;
53
+ }
54
+ }
55
+
56
+ throw new _validationError.default("Value must be a valid URL.");
57
+ };
58
+
59
+ exports.default = _default;
@@ -0,0 +1 @@
1
+ {"version":3,"names":["regex","base","RegExp","ip","relative","href","value","params","startsWith","replace","test","includes","ValidationError"],"sources":["url.ts"],"sourcesContent":["import ValidationError from \"~/validationError\";\n\nconst regex = {\n base: new RegExp(\n // eslint-disable-next-line\n /^(https?:\\/\\/)((([a-z\\d]([a-z\\d-]*[a-z\\d])*)\\.)+[a-z]{2,}|((\\d{1,3}\\.){3}\\d{1,3}))(\\:\\d+)?(\\/[-a-z\\d%_.~+]*)*(\\?[;&a-z\\d%_.~+=!-]*)?(\\#[-a-z\\d_]*)?$/i\n ),\n ip: new RegExp(\n // eslint-disable-next-line\n /^(https?:\\/\\/)(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)$/\n ),\n relative: new RegExp(\n // eslint-disable-next-line\n /^\\/.*$/\n ),\n href: new RegExp(\n // eslint-disable-next-line\n /^(#|mailto:|tel:)\\S*$/\n )\n};\n\nexport default (value: any, params?: string[]) => {\n if (!value || !params) {\n return;\n }\n value = value + \"\";\n\n if (value.startsWith(\"http://localhost\") || value.startsWith(\"https://localhost\")) {\n value = value.replace(\"//localhost\", \"//localhost.com\");\n }\n\n if (regex.base.test(value)) {\n if (!params.includes(\"noIp\")) {\n return;\n }\n\n if (!regex.ip.test(value)) {\n return;\n }\n }\n\n if (params.includes(\"allowRelative\")) {\n if (regex.relative.test(value)) {\n return;\n }\n }\n\n if (params.includes(\"allowHref\")) {\n if (regex.href.test(value)) {\n return;\n }\n }\n\n throw new ValidationError(\"Value must be a valid URL.\");\n};\n"],"mappings":";;;;;;;;;AAAA;;AAEA,MAAMA,KAAK,GAAG;EACVC,IAAI,EAAE,IAAIC,MAAJ,EACF;EACA,uJAFE,CADI;EAKVC,EAAE,EAAE,IAAID,MAAJ,EACA;EACA,+KAFA,CALM;EASVE,QAAQ,EAAE,IAAIF,MAAJ,EACN;EACA,QAFM,CATA;EAaVG,IAAI,EAAE,IAAIH,MAAJ,EACF;EACA,uBAFE;AAbI,CAAd;;eAmBe,CAACI,KAAD,EAAaC,MAAb,KAAmC;EAC9C,IAAI,CAACD,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