namefully 1.1.0 → 1.2.1

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 (136) hide show
  1. package/dist/lib/config.js +112 -0
  2. package/dist/lib/constants.js +30 -0
  3. package/dist/lib/error.js +92 -0
  4. package/dist/lib/full-name.js +115 -0
  5. package/dist/lib/index.js +27 -12
  6. package/dist/lib/name.js +230 -0
  7. package/dist/lib/namefully.js +368 -681
  8. package/dist/lib/parser.js +138 -0
  9. package/dist/lib/types.js +107 -0
  10. package/dist/lib/utils.js +92 -0
  11. package/dist/lib/validator.js +301 -0
  12. package/dist/types/config.d.ts +97 -0
  13. package/dist/types/constants.d.ts +4 -0
  14. package/dist/types/error.d.ts +158 -0
  15. package/dist/types/full-name.d.ts +54 -0
  16. package/dist/types/index.d.ts +21 -0
  17. package/dist/types/name.d.ts +126 -0
  18. package/dist/types/namefully.d.ts +313 -0
  19. package/dist/types/parser.d.ts +41 -0
  20. package/dist/types/types.d.ts +127 -0
  21. package/dist/types/utils.d.ts +53 -0
  22. package/dist/types/validator.d.ts +57 -0
  23. package/dist/umd/namefully.js +1503 -2900
  24. package/dist/umd/namefully.min.js +1 -3
  25. package/package.json +28 -38
  26. package/readme.md +138 -167
  27. package/changelog.md +0 -134
  28. package/dist/lib/core/constants.d.ts +0 -48
  29. package/dist/lib/core/constants.js +0 -101
  30. package/dist/lib/core/constants.js.map +0 -1
  31. package/dist/lib/core/core.d.ts +0 -17
  32. package/dist/lib/core/core.js +0 -24
  33. package/dist/lib/core/core.js.map +0 -1
  34. package/dist/lib/core/index.d.ts +0 -9
  35. package/dist/lib/core/index.js +0 -13
  36. package/dist/lib/core/index.js.map +0 -1
  37. package/dist/lib/core/parsers/array-name.parser.d.ts +0 -41
  38. package/dist/lib/core/parsers/array-name.parser.js +0 -86
  39. package/dist/lib/core/parsers/array-name.parser.js.map +0 -1
  40. package/dist/lib/core/parsers/array-string.parser.d.ts +0 -47
  41. package/dist/lib/core/parsers/array-string.parser.js +0 -95
  42. package/dist/lib/core/parsers/array-string.parser.js.map +0 -1
  43. package/dist/lib/core/parsers/index.d.ts +0 -11
  44. package/dist/lib/core/parsers/index.js +0 -11
  45. package/dist/lib/core/parsers/index.js.map +0 -1
  46. package/dist/lib/core/parsers/nama.parser.d.ts +0 -33
  47. package/dist/lib/core/parsers/nama.parser.js +0 -74
  48. package/dist/lib/core/parsers/nama.parser.js.map +0 -1
  49. package/dist/lib/core/parsers/parser.d.ts +0 -28
  50. package/dist/lib/core/parsers/parser.js +0 -3
  51. package/dist/lib/core/parsers/parser.js.map +0 -1
  52. package/dist/lib/core/parsers/string.parser.d.ts +0 -60
  53. package/dist/lib/core/parsers/string.parser.js +0 -62
  54. package/dist/lib/core/parsers/string.parser.js.map +0 -1
  55. package/dist/lib/core/utils.d.ts +0 -52
  56. package/dist/lib/core/utils.js +0 -178
  57. package/dist/lib/core/utils.js.map +0 -1
  58. package/dist/lib/index.d.ts +0 -10
  59. package/dist/lib/index.js.map +0 -1
  60. package/dist/lib/models/enums.d.ts +0 -106
  61. package/dist/lib/models/enums.js +0 -114
  62. package/dist/lib/models/enums.js.map +0 -1
  63. package/dist/lib/models/firstname.d.ts +0 -77
  64. package/dist/lib/models/firstname.js +0 -131
  65. package/dist/lib/models/firstname.js.map +0 -1
  66. package/dist/lib/models/fullname.d.ts +0 -73
  67. package/dist/lib/models/fullname.js +0 -99
  68. package/dist/lib/models/fullname.js.map +0 -1
  69. package/dist/lib/models/index.d.ts +0 -13
  70. package/dist/lib/models/index.js +0 -16
  71. package/dist/lib/models/index.js.map +0 -1
  72. package/dist/lib/models/lastname.d.ts +0 -80
  73. package/dist/lib/models/lastname.js +0 -157
  74. package/dist/lib/models/lastname.js.map +0 -1
  75. package/dist/lib/models/misc.d.ts +0 -108
  76. package/dist/lib/models/misc.js +0 -3
  77. package/dist/lib/models/misc.js.map +0 -1
  78. package/dist/lib/models/name.d.ts +0 -76
  79. package/dist/lib/models/name.js +0 -115
  80. package/dist/lib/models/name.js.map +0 -1
  81. package/dist/lib/models/summary.d.ts +0 -26
  82. package/dist/lib/models/summary.js +0 -61
  83. package/dist/lib/models/summary.js.map +0 -1
  84. package/dist/lib/namefully.d.ts +0 -302
  85. package/dist/lib/namefully.js.map +0 -1
  86. package/dist/lib/validators/array-name.validator.d.ts +0 -25
  87. package/dist/lib/validators/array-name.validator.js +0 -75
  88. package/dist/lib/validators/array-name.validator.js.map +0 -1
  89. package/dist/lib/validators/array-string.validator.d.ts +0 -43
  90. package/dist/lib/validators/array-string.validator.js +0 -76
  91. package/dist/lib/validators/array-string.validator.js.map +0 -1
  92. package/dist/lib/validators/common/validation-error.d.ts +0 -19
  93. package/dist/lib/validators/common/validation-error.js +0 -26
  94. package/dist/lib/validators/common/validation-error.js.map +0 -1
  95. package/dist/lib/validators/common/validation-rule.d.ts +0 -72
  96. package/dist/lib/validators/common/validation-rule.js +0 -76
  97. package/dist/lib/validators/common/validation-rule.js.map +0 -1
  98. package/dist/lib/validators/common/validation-type.d.ts +0 -24
  99. package/dist/lib/validators/common/validation-type.js +0 -28
  100. package/dist/lib/validators/common/validation-type.js.map +0 -1
  101. package/dist/lib/validators/firstname.validator.d.ts +0 -20
  102. package/dist/lib/validators/firstname.validator.js +0 -29
  103. package/dist/lib/validators/firstname.validator.js.map +0 -1
  104. package/dist/lib/validators/fullname.validator.d.ts +0 -21
  105. package/dist/lib/validators/fullname.validator.js +0 -38
  106. package/dist/lib/validators/fullname.validator.js.map +0 -1
  107. package/dist/lib/validators/index.d.ts +0 -21
  108. package/dist/lib/validators/index.js +0 -35
  109. package/dist/lib/validators/index.js.map +0 -1
  110. package/dist/lib/validators/lastname.validator.d.ts +0 -20
  111. package/dist/lib/validators/lastname.validator.js +0 -29
  112. package/dist/lib/validators/lastname.validator.js.map +0 -1
  113. package/dist/lib/validators/middlename.validator.d.ts +0 -20
  114. package/dist/lib/validators/middlename.validator.js +0 -38
  115. package/dist/lib/validators/middlename.validator.js.map +0 -1
  116. package/dist/lib/validators/nama.validator.d.ts +0 -21
  117. package/dist/lib/validators/nama.validator.js +0 -44
  118. package/dist/lib/validators/nama.validator.js.map +0 -1
  119. package/dist/lib/validators/namon.validator.d.ts +0 -20
  120. package/dist/lib/validators/namon.validator.js +0 -29
  121. package/dist/lib/validators/namon.validator.js.map +0 -1
  122. package/dist/lib/validators/prefix.validator.d.ts +0 -14
  123. package/dist/lib/validators/prefix.validator.js +0 -31
  124. package/dist/lib/validators/prefix.validator.js.map +0 -1
  125. package/dist/lib/validators/string-name.validator.d.ts +0 -20
  126. package/dist/lib/validators/string-name.validator.js +0 -29
  127. package/dist/lib/validators/string-name.validator.js.map +0 -1
  128. package/dist/lib/validators/suffix.validator.d.ts +0 -14
  129. package/dist/lib/validators/suffix.validator.js +0 -31
  130. package/dist/lib/validators/suffix.validator.js.map +0 -1
  131. package/dist/lib/validators/validator.d.ts +0 -13
  132. package/dist/lib/validators/validator.js +0 -9
  133. package/dist/lib/validators/validator.js.map +0 -1
  134. package/dist/umd/namefully.js.map +0 -1
  135. package/dist/umd/namefully.min.js.LICENSE.txt +0 -29
  136. package/dist/umd/namefully.min.js.map +0 -1
@@ -1,72 +0,0 @@
1
- /**
2
- * Validation rules
3
- *
4
- * Created on March 06, 2020
5
- * @author Ralph Florent <ralflornt@gmail.com>
6
- */
7
- /**
8
- * Represents a set of validation rules (regex)
9
- * @class
10
- * @static
11
- *
12
- * This regex is intented to match specific alphabets only as a person name does
13
- * not contain special characters. `\w` does not cover non-Latin characters. So,
14
- * it is extended using unicode chars to cover more cases (e.g., Icelandic).
15
- * It matches as follows:
16
- * [a-z]: Latin alphabet from a (index 97) to z (index 122)
17
- * [A-Z]: Latin alphabet from A (index 65) to Z (index 90)
18
- * [\u00C0-\u00D6]: Latin/German chars from À (index 192) to Ö (index 214)
19
- * [\u00D8-\u00f6]: German/Icelandic chars from Ø (index 216) to ö (index 246)
20
- * [\u00f8-\u00ff]: German/Icelandic chars from ø (index 248) to ÿ (index 255)
21
- * [\u0400-\u04FF]: Cyrillic alphabet from Ѐ (index 1024) to ӿ (index 1279)
22
- * [Ά-ωΑ-ώ]: Greek alphabet from Ά (index 902) to ω (index 969)
23
- */
24
- export declare class ValidationRule {
25
- static base: RegExp;
26
- /**
27
- * Matches one name part (namon) that is of nature:
28
- * - Latin (English, Spanish, French, etc.)
29
- * - European (Greek, Cyrillic, Icelandic, German)
30
- * - hyphenated
31
- * - with apostrophe
32
- * - with space
33
- */
34
- static namon: RegExp;
35
- /**
36
- * Matches 1+ name parts (namon) that are of nature:
37
- * - Latin (English, Spanish, French, etc.)
38
- * - European (Greek, Cyrillic, Icelandic, German)
39
- * - hyphenated
40
- * - with apostrophe
41
- * - with comma
42
- * - with period
43
- * - with space
44
- */
45
- static fullname: RegExp;
46
- /**
47
- * Matches one name part (namon) that is of nature:
48
- * - Latin (English, Spanish, French, etc.)
49
- * - European (Greek, Cyrillic, Icelandic, German)
50
- * - hyphenated
51
- * - with apostrophe
52
- */
53
- static firstname: RegExp;
54
- /**
55
- * Matches 1+ names part (namon) that are of nature:
56
- * - Latin (English, Spanish, French, etc.)
57
- * - European (Greek, Cyrillic, Icelandic, German)
58
- * - hyphenated
59
- * - with apostrophe
60
- * - with space
61
- */
62
- static middlename: RegExp;
63
- /**
64
- * Matches one name part (namon) that is of nature:
65
- * - Latin (English, Spanish, French, etc.)
66
- * - European (Greek, Cyrillic, Icelandic, German)
67
- * - hyphenated
68
- * - with apostrophe
69
- * - with space
70
- */
71
- static lastname: RegExp;
72
- }
@@ -1,76 +0,0 @@
1
- "use strict";
2
- /**
3
- * Validation rules
4
- *
5
- * Created on March 06, 2020
6
- * @author Ralph Florent <ralflornt@gmail.com>
7
- */
8
- Object.defineProperty(exports, "__esModule", { value: true });
9
- /**
10
- * Represents a set of validation rules (regex)
11
- * @class
12
- * @static
13
- *
14
- * This regex is intented to match specific alphabets only as a person name does
15
- * not contain special characters. `\w` does not cover non-Latin characters. So,
16
- * it is extended using unicode chars to cover more cases (e.g., Icelandic).
17
- * It matches as follows:
18
- * [a-z]: Latin alphabet from a (index 97) to z (index 122)
19
- * [A-Z]: Latin alphabet from A (index 65) to Z (index 90)
20
- * [\u00C0-\u00D6]: Latin/German chars from À (index 192) to Ö (index 214)
21
- * [\u00D8-\u00f6]: German/Icelandic chars from Ø (index 216) to ö (index 246)
22
- * [\u00f8-\u00ff]: German/Icelandic chars from ø (index 248) to ÿ (index 255)
23
- * [\u0400-\u04FF]: Cyrillic alphabet from Ѐ (index 1024) to ӿ (index 1279)
24
- * [Ά-ωΑ-ώ]: Greek alphabet from Ά (index 902) to ω (index 969)
25
- */
26
- class ValidationRule {
27
- }
28
- exports.ValidationRule = ValidationRule;
29
- ValidationRule.base = /[a-zA-Z\u00C0-\u00D6\u00D8-\u00f6\u00f8-\u00ff\u0400-\u04FFΆ-ωΑ-ώ]/;
30
- /**
31
- * Matches one name part (namon) that is of nature:
32
- * - Latin (English, Spanish, French, etc.)
33
- * - European (Greek, Cyrillic, Icelandic, German)
34
- * - hyphenated
35
- * - with apostrophe
36
- * - with space
37
- */
38
- ValidationRule.namon = new RegExp(`^${ValidationRule.base.source}+(([' -]${ValidationRule.base.source})?${ValidationRule.base.source}*)*$`);
39
- /**
40
- * Matches 1+ name parts (namon) that are of nature:
41
- * - Latin (English, Spanish, French, etc.)
42
- * - European (Greek, Cyrillic, Icelandic, German)
43
- * - hyphenated
44
- * - with apostrophe
45
- * - with comma
46
- * - with period
47
- * - with space
48
- */
49
- ValidationRule.fullname = new RegExp(`^${ValidationRule.base.source}+(([',. -]${ValidationRule.base.source})?${ValidationRule.base.source}*)*$`);
50
- /**
51
- * Matches one name part (namon) that is of nature:
52
- * - Latin (English, Spanish, French, etc.)
53
- * - European (Greek, Cyrillic, Icelandic, German)
54
- * - hyphenated
55
- * - with apostrophe
56
- */
57
- ValidationRule.firstname = ValidationRule.namon;
58
- /**
59
- * Matches 1+ names part (namon) that are of nature:
60
- * - Latin (English, Spanish, French, etc.)
61
- * - European (Greek, Cyrillic, Icelandic, German)
62
- * - hyphenated
63
- * - with apostrophe
64
- * - with space
65
- */
66
- ValidationRule.middlename = new RegExp(`^${ValidationRule.base.source}+(([' -]${ValidationRule.base.source})?${ValidationRule.base.source}*)*$`);
67
- /**
68
- * Matches one name part (namon) that is of nature:
69
- * - Latin (English, Spanish, French, etc.)
70
- * - European (Greek, Cyrillic, Icelandic, German)
71
- * - hyphenated
72
- * - with apostrophe
73
- * - with space
74
- */
75
- ValidationRule.lastname = ValidationRule.namon;
76
- //# sourceMappingURL=validation-rule.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"validation-rule.js","sourceRoot":"","sources":["../../../../src/validators/common/validation-rule.ts"],"names":[],"mappings":";AAAA;;;;;GAKG;;AAEH;;;;;;;;;;;;;;;;GAgBG;AACH,MAAa,cAAc;;AAA3B,wCAoDC;AAnDU,mBAAI,GAAW,oEAAoE,CAAA;AAC1F;;;;;;;GAOG;AACI,oBAAK,GAAW,IAAI,MAAM,CAAC,IAAI,cAAc,CAAC,IAAI,CAAC,MAAM,WAAW,cAAc,CAAC,IAAI,CAAC,MAAM,KAAK,cAAc,CAAC,IAAI,CAAC,MAAM,MAAM,CAAC,CAAC;AAE5I;;;;;;;;;GASG;AACI,uBAAQ,GAAW,IAAI,MAAM,CAAC,IAAI,cAAc,CAAC,IAAI,CAAC,MAAM,aAAa,cAAc,CAAC,IAAI,CAAC,MAAM,KAAK,cAAc,CAAC,IAAI,CAAC,MAAM,MAAM,CAAC,CAAC;AAEjJ;;;;;;GAMG;AACI,wBAAS,GAAW,cAAc,CAAC,KAAK,CAAC;AAEhD;;;;;;;GAOG;AACI,yBAAU,GAAW,IAAI,MAAM,CAAC,IAAI,cAAc,CAAC,IAAI,CAAC,MAAM,WAAW,cAAc,CAAC,IAAI,CAAC,MAAM,KAAK,cAAc,CAAC,IAAI,CAAC,MAAM,MAAM,CAAC,CAAC;AAEjJ;;;;;;;GAOG;AACI,uBAAQ,GAAW,cAAc,CAAC,KAAK,CAAC"}
@@ -1,24 +0,0 @@
1
- /**
2
- * Validation types
3
- *
4
- * Created on March 06, 2020
5
- * @author Ralph Florent <ralflornt@gmail.com>
6
- */
7
- /**
8
- * Enum for the validation types
9
- * @enum
10
- */
11
- export declare enum ValidatorType {
12
- NONE = 0,
13
- NAMON = 1,
14
- NAMA = 2,
15
- ARR_NAMES = 3,
16
- ARR_STRING = 4,
17
- FULL_NAME = 5,
18
- PREFIX = 6,
19
- FIRST_NAME = 7,
20
- MIDDLE_NAME = 8,
21
- LAST_NAME = 9,
22
- SUFFIX = 10,
23
- CUSTOM = 11
24
- }
@@ -1,28 +0,0 @@
1
- "use strict";
2
- /**
3
- * Validation types
4
- *
5
- * Created on March 06, 2020
6
- * @author Ralph Florent <ralflornt@gmail.com>
7
- */
8
- Object.defineProperty(exports, "__esModule", { value: true });
9
- /**
10
- * Enum for the validation types
11
- * @enum
12
- */
13
- var ValidatorType;
14
- (function (ValidatorType) {
15
- ValidatorType[ValidatorType["NONE"] = 0] = "NONE";
16
- ValidatorType[ValidatorType["NAMON"] = 1] = "NAMON";
17
- ValidatorType[ValidatorType["NAMA"] = 2] = "NAMA";
18
- ValidatorType[ValidatorType["ARR_NAMES"] = 3] = "ARR_NAMES";
19
- ValidatorType[ValidatorType["ARR_STRING"] = 4] = "ARR_STRING";
20
- ValidatorType[ValidatorType["FULL_NAME"] = 5] = "FULL_NAME";
21
- ValidatorType[ValidatorType["PREFIX"] = 6] = "PREFIX";
22
- ValidatorType[ValidatorType["FIRST_NAME"] = 7] = "FIRST_NAME";
23
- ValidatorType[ValidatorType["MIDDLE_NAME"] = 8] = "MIDDLE_NAME";
24
- ValidatorType[ValidatorType["LAST_NAME"] = 9] = "LAST_NAME";
25
- ValidatorType[ValidatorType["SUFFIX"] = 10] = "SUFFIX";
26
- ValidatorType[ValidatorType["CUSTOM"] = 11] = "CUSTOM";
27
- })(ValidatorType = exports.ValidatorType || (exports.ValidatorType = {}));
28
- //# sourceMappingURL=validation-type.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"validation-type.js","sourceRoot":"","sources":["../../../../src/validators/common/validation-type.ts"],"names":[],"mappings":";AAAA;;;;;GAKG;;AAEH;;;GAGG;AACH,IAAY,aAcX;AAdD,WAAY,aAAa;IACrB,iDAAI,CAAA;IACJ,mDAAK,CAAA;IACL,iDAAI,CAAA;IACJ,2DAAS,CAAA;IACT,6DAAU,CAAA;IACV,2DAAS,CAAA;IACT,qDAAM,CAAA;IACN,6DAAU,CAAA;IACV,+DAAW,CAAA;IACX,2DAAS,CAAA;IACT,sDAAM,CAAA;IAEN,sDAAM,CAAA;AACV,CAAC,EAdW,aAAa,GAAb,qBAAa,KAAb,qBAAa,QAcxB"}
@@ -1,20 +0,0 @@
1
- /**
2
- * First name validator
3
- *
4
- * Created on March 15, 2020
5
- * @author Ralph Florent <ralflornt@gmail.com>
6
- */
7
- import { Validator, ValidatorType } from './index';
8
- /**
9
- * Represents a first name validator
10
- * @class
11
- * @implements {Validator}
12
- */
13
- export default class FirstnameValidator implements Validator<string> {
14
- readonly type: ValidatorType;
15
- /**
16
- * Validates the content of a first name
17
- * @param {string} value data to validate
18
- */
19
- validate(value: string): void;
20
- }
@@ -1,29 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- /**
4
- * First name validator
5
- *
6
- * Created on March 15, 2020
7
- * @author Ralph Florent <ralflornt@gmail.com>
8
- */
9
- const index_1 = require("./index");
10
- /**
11
- * Represents a first name validator
12
- * @class
13
- * @implements {Validator}
14
- */
15
- class FirstnameValidator {
16
- constructor() {
17
- this.type = index_1.ValidatorType.FIRST_NAME;
18
- }
19
- /**
20
- * Validates the content of a first name
21
- * @param {string} value data to validate
22
- */
23
- validate(value) {
24
- if (!index_1.ValidationRule.firstname.test(value))
25
- throw new index_1.ValidationError(`invalid string content '${value}'`, 'First name');
26
- }
27
- }
28
- exports.default = FirstnameValidator;
29
- //# sourceMappingURL=firstname.validator.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"firstname.validator.js","sourceRoot":"","sources":["../../../src/validators/firstname.validator.ts"],"names":[],"mappings":";;AAAA;;;;;GAKG;AACH,mCAAoF;AAEpF;;;;GAIG;AACH,MAAqB,kBAAkB;IAAvC;QACa,SAAI,GAAkB,qBAAa,CAAC,UAAU,CAAC;IAS5D,CAAC;IARG;;;OAGG;IACH,QAAQ,CAAC,KAAa;QAClB,IAAI,CAAC,sBAAc,CAAC,SAAS,CAAC,IAAI,CAAC,KAAK,CAAC;YACrC,MAAM,IAAI,uBAAe,CAAC,2BAA2B,KAAK,GAAG,EAAE,YAAY,CAAC,CAAC;IACrF,CAAC;CACJ;AAVD,qCAUC"}
@@ -1,21 +0,0 @@
1
- /**
2
- * `Fullname` validator
3
- *
4
- * Created on March 15, 2020
5
- * @author Ralph Florent <ralflornt@gmail.com>
6
- */
7
- import { Fullname } from '../models/index';
8
- import { Validator, ValidatorType } from './index';
9
- /**
10
- * Represents a `Fullname` (JSON signature) validator for provided custom parser
11
- * @class
12
- * @implements {Validator}
13
- */
14
- export default class FullnameValidator implements Validator<Fullname> {
15
- readonly type: ValidatorType;
16
- /**
17
- * Validates that the `Fullname` contract is met
18
- * @param {Fullname} value data to validate
19
- */
20
- validate(v: Fullname): void;
21
- }
@@ -1,38 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- /**
4
- * `Fullname` validator
5
- *
6
- * Created on March 15, 2020
7
- * @author Ralph Florent <ralflornt@gmail.com>
8
- */
9
- const index_1 = require("../models/index");
10
- const index_2 = require("./index");
11
- /**
12
- * Represents a `Fullname` (JSON signature) validator for provided custom parser
13
- * @class
14
- * @implements {Validator}
15
- */
16
- class FullnameValidator {
17
- constructor() {
18
- this.type = index_2.ValidatorType.FULL_NAME;
19
- }
20
- /**
21
- * Validates that the `Fullname` contract is met
22
- * @param {Fullname} value data to validate
23
- */
24
- validate(v) {
25
- if (!v.firstname || !(v.firstname instanceof index_1.Firstname))
26
- throw new index_2.ValidationError('first name is corrupted', 'Fullname');
27
- if (!v.lastname || !(v.lastname instanceof index_1.Lastname))
28
- throw new index_2.ValidationError('last name is corrupted', 'Fullname');
29
- if (v.middlename && !(v.middlename instanceof Array))
30
- throw new index_2.ValidationError('middle name is corrupted', 'Fullname');
31
- if (v.prefix)
32
- new index_2.PrefixValidator().validate(v.prefix);
33
- if (v.suffix)
34
- new index_2.SuffixValidator().validate(v.suffix);
35
- }
36
- }
37
- exports.default = FullnameValidator;
38
- //# sourceMappingURL=fullname.validator.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"fullname.validator.js","sourceRoot":"","sources":["../../../src/validators/fullname.validator.ts"],"names":[],"mappings":";;AAAA;;;;;GAKG;AACH,2CAAgE;AAChE,mCAAsG;AAEtG;;;;GAIG;AACH,MAAqB,iBAAiB;IAAtC;QACa,SAAI,GAAkB,qBAAa,CAAC,SAAS,CAAC;IAiB3D,CAAC;IAhBG;;;OAGG;IACH,QAAQ,CAAC,CAAW;QAChB,IAAI,CAAC,CAAC,CAAC,SAAS,IAAI,CAAC,CAAC,CAAC,CAAC,SAAS,YAAY,iBAAS,CAAC;YACnD,MAAM,IAAI,uBAAe,CAAC,yBAAyB,EAAE,UAAU,CAAC,CAAC;QACrE,IAAI,CAAC,CAAC,CAAC,QAAQ,IAAI,CAAC,CAAC,CAAC,CAAC,QAAQ,YAAY,gBAAQ,CAAC;YAChD,MAAM,IAAI,uBAAe,CAAC,wBAAwB,EAAE,UAAU,CAAC,CAAC;QACpE,IAAI,CAAC,CAAC,UAAU,IAAI,CAAC,CAAC,CAAC,CAAC,UAAU,YAAY,KAAK,CAAC;YAChD,MAAM,IAAI,uBAAe,CAAC,0BAA0B,EAAE,UAAU,CAAC,CAAC;QACtE,IAAI,CAAC,CAAC,MAAM;YACR,IAAI,uBAAe,EAAE,CAAC,QAAQ,CAAC,CAAC,CAAC,MAAM,CAAC,CAAA;QAC5C,IAAI,CAAC,CAAC,MAAM;YACR,IAAI,uBAAe,EAAE,CAAC,QAAQ,CAAC,CAAC,CAAC,MAAM,CAAC,CAAA;IAChD,CAAC;CACJ;AAlBD,oCAkBC"}
@@ -1,21 +0,0 @@
1
- /**
2
- * Make all the locals available
3
- *
4
- * Created on March 06, 2020
5
- * @author Ralph Florent <ralflornt@gmail.com>
6
- */
7
- export * from './common/validation-rule';
8
- export * from './common/validation-type';
9
- export * from './common/validation-error';
10
- export * from './validator';
11
- export { default as NamonValidator } from './namon.validator';
12
- export { default as PrefixValidator } from './prefix.validator';
13
- export { default as SuffixValidator } from './suffix.validator';
14
- export { default as FirstnameValidator } from './firstname.validator';
15
- export { default as LastnameValidator } from './lastname.validator';
16
- export { default as MiddlenameValidator } from './middlename.validator';
17
- export { default as FullnameValidator } from './fullname.validator';
18
- export { default as NamaValidator } from './nama.validator';
19
- export { default as ArrayNameValidator } from './array-name.validator';
20
- export { default as ArrayStringValidator } from './array-string.validator';
21
- export { default as StringNameValidator } from './string-name.validator';
@@ -1,35 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- const tslib_1 = require("tslib");
4
- /**
5
- * Make all the locals available
6
- *
7
- * Created on March 06, 2020
8
- * @author Ralph Florent <ralflornt@gmail.com>
9
- */
10
- tslib_1.__exportStar(require("./common/validation-rule"), exports);
11
- tslib_1.__exportStar(require("./common/validation-type"), exports);
12
- tslib_1.__exportStar(require("./common/validation-error"), exports);
13
- var namon_validator_1 = require("./namon.validator");
14
- exports.NamonValidator = namon_validator_1.default;
15
- var prefix_validator_1 = require("./prefix.validator");
16
- exports.PrefixValidator = prefix_validator_1.default;
17
- var suffix_validator_1 = require("./suffix.validator");
18
- exports.SuffixValidator = suffix_validator_1.default;
19
- var firstname_validator_1 = require("./firstname.validator");
20
- exports.FirstnameValidator = firstname_validator_1.default;
21
- var lastname_validator_1 = require("./lastname.validator");
22
- exports.LastnameValidator = lastname_validator_1.default;
23
- var middlename_validator_1 = require("./middlename.validator");
24
- exports.MiddlenameValidator = middlename_validator_1.default;
25
- var fullname_validator_1 = require("./fullname.validator");
26
- exports.FullnameValidator = fullname_validator_1.default;
27
- var nama_validator_1 = require("./nama.validator");
28
- exports.NamaValidator = nama_validator_1.default;
29
- var array_name_validator_1 = require("./array-name.validator");
30
- exports.ArrayNameValidator = array_name_validator_1.default;
31
- var array_string_validator_1 = require("./array-string.validator");
32
- exports.ArrayStringValidator = array_string_validator_1.default;
33
- var string_name_validator_1 = require("./string-name.validator");
34
- exports.StringNameValidator = string_name_validator_1.default;
35
- //# sourceMappingURL=index.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/validators/index.ts"],"names":[],"mappings":";;;AAAA;;;;;GAKG;AACH,mEAAyC;AACzC,mEAAyC;AACzC,oEAA0C;AAG1C,qDAA8D;AAArD,2CAAA,OAAO,CAAkB;AAClC,uDAAgE;AAAvD,6CAAA,OAAO,CAAmB;AACnC,uDAAgE;AAAvD,6CAAA,OAAO,CAAmB;AACnC,6DAAsE;AAA7D,mDAAA,OAAO,CAAsB;AACtC,2DAAoE;AAA3D,iDAAA,OAAO,CAAqB;AACrC,+DAAwE;AAA/D,qDAAA,OAAO,CAAuB;AACvC,2DAAoE;AAA3D,iDAAA,OAAO,CAAqB;AACrC,mDAA4D;AAAnD,yCAAA,OAAO,CAAiB;AAEjC,+DAAsE;AAA9D,oDAAA,OAAO,CAAsB;AACrC,mEAA0E;AAAlE,wDAAA,OAAO,CAAwB;AACvC,iEAAwE;AAAhE,sDAAA,OAAO,CAAuB"}
@@ -1,20 +0,0 @@
1
- /**
2
- * Last name validator
3
- *
4
- * Created on March 15, 2020
5
- * @author Ralph Florent <ralflornt@gmail.com>
6
- */
7
- import { Validator, ValidatorType } from './index';
8
- /**
9
- * Represents a last name validator
10
- * @class
11
- * @implements {Validator}
12
- */
13
- export default class LastnameValidator implements Validator<string> {
14
- readonly type: ValidatorType;
15
- /**
16
- * Validates the content of a last name
17
- * @param {string} value data to validate
18
- */
19
- validate(value: string): void;
20
- }
@@ -1,29 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- /**
4
- * Last name validator
5
- *
6
- * Created on March 15, 2020
7
- * @author Ralph Florent <ralflornt@gmail.com>
8
- */
9
- const index_1 = require("./index");
10
- /**
11
- * Represents a last name validator
12
- * @class
13
- * @implements {Validator}
14
- */
15
- class LastnameValidator {
16
- constructor() {
17
- this.type = index_1.ValidatorType.LAST_NAME;
18
- }
19
- /**
20
- * Validates the content of a last name
21
- * @param {string} value data to validate
22
- */
23
- validate(value) {
24
- if (!index_1.ValidationRule.lastname.test(value))
25
- throw new index_1.ValidationError(`invalid string content '${value}'`, 'Last name');
26
- }
27
- }
28
- exports.default = LastnameValidator;
29
- //# sourceMappingURL=lastname.validator.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"lastname.validator.js","sourceRoot":"","sources":["../../../src/validators/lastname.validator.ts"],"names":[],"mappings":";;AAAA;;;;;GAKG;AACH,mCAAoF;AAEpF;;;;GAIG;AACH,MAAqB,iBAAiB;IAAtC;QACa,SAAI,GAAkB,qBAAa,CAAC,SAAS,CAAC;IAS3D,CAAC;IARG;;;OAGG;IACH,QAAQ,CAAC,KAAa;QAClB,IAAI,CAAC,sBAAc,CAAC,QAAQ,CAAC,IAAI,CAAC,KAAK,CAAC;YACpC,MAAM,IAAI,uBAAe,CAAC,2BAA2B,KAAK,GAAG,EAAE,WAAW,CAAC,CAAC;IACpF,CAAC;CACJ;AAVD,oCAUC"}
@@ -1,20 +0,0 @@
1
- /**
2
- * Middle name validator
3
- *
4
- * Created on March 15, 2020
5
- * @author Ralph Florent <ralflornt@gmail.com>
6
- */
7
- import { Validator, ValidatorType } from './index';
8
- /**
9
- * Represents a middle name validator
10
- * @class
11
- * @implements {Validator}
12
- */
13
- export default class MiddlenameValidator implements Validator<string | string[]> {
14
- readonly type: ValidatorType;
15
- /**
16
- * Validates the content of a list of middle names
17
- * @param {string | string[]} values to validate
18
- */
19
- validate(values: string | string[]): void;
20
- }
@@ -1,38 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- /**
4
- * Middle name validator
5
- *
6
- * Created on March 15, 2020
7
- * @author Ralph Florent <ralflornt@gmail.com>
8
- */
9
- const index_1 = require("./index");
10
- /**
11
- * Represents a middle name validator
12
- * @class
13
- * @implements {Validator}
14
- */
15
- class MiddlenameValidator {
16
- constructor() {
17
- this.type = index_1.ValidatorType.MIDDLE_NAME;
18
- }
19
- /**
20
- * Validates the content of a list of middle names
21
- * @param {string | string[]} values to validate
22
- */
23
- validate(values) {
24
- if (typeof values === 'string') {
25
- if (!index_1.ValidationRule.middlename.test(values))
26
- throw new index_1.ValidationError(`invalid string content '${values}'`, 'Middle name');
27
- }
28
- else if (values instanceof Array) {
29
- const namonValidator = new index_1.NamonValidator();
30
- values.forEach(v => namonValidator.validate(v));
31
- }
32
- else {
33
- throw new Error('Expecting string or Array<string> type');
34
- }
35
- }
36
- }
37
- exports.default = MiddlenameValidator;
38
- //# sourceMappingURL=middlename.validator.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"middlename.validator.js","sourceRoot":"","sources":["../../../src/validators/middlename.validator.ts"],"names":[],"mappings":";;AAAA;;;;;GAKG;AACH,mCAAoG;AAEpG;;;;GAIG;AACH,MAAqB,mBAAmB;IAAxC;QACa,SAAI,GAAkB,qBAAa,CAAC,WAAW,CAAC;IAiB7D,CAAC;IAhBG;;;OAGG;IACH,QAAQ,CAAC,MAAyB;QAE9B,IAAI,OAAO,MAAM,KAAK,QAAQ,EAAE;YAC5B,IAAI,CAAC,sBAAc,CAAC,UAAU,CAAC,IAAI,CAAC,MAAM,CAAC;gBACvC,MAAM,IAAI,uBAAe,CAAC,2BAA2B,MAAM,GAAG,EAAE,aAAa,CAAC,CAAC;SACtF;aAAM,IAAI,MAAM,YAAY,KAAK,EAAE;YAChC,MAAM,cAAc,GAAG,IAAI,sBAAc,EAAE,CAAC;YAC3C,MAAmB,CAAC,OAAO,CAAC,CAAC,CAAC,EAAE,CAAC,cAAc,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC,CAAC;SACjE;aAAM;YACH,MAAM,IAAI,KAAK,CAAC,wCAAwC,CAAC,CAAC;SAC7D;IACL,CAAC;CACJ;AAlBD,sCAkBC"}
@@ -1,21 +0,0 @@
1
- /**
2
- * Nama validator
3
- *
4
- * Created on March 15, 2020
5
- * @author Ralph Florent <ralflornt@gmail.com>
6
- */
7
- import { Nama } from '../models';
8
- import { Validator, ValidatorType } from './index';
9
- /**
10
- * Represents a `Nama` validator to help the nama parser
11
- * @class
12
- * @implements {Validator}
13
- */
14
- export default class NamaValidator implements Validator<Nama> {
15
- readonly type: ValidatorType;
16
- /**
17
- * Validates the content of a JSON-formatted names
18
- * @param {string} value data to validate
19
- */
20
- validate(value: Nama): void;
21
- }
@@ -1,44 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- /**
4
- * Nama validator
5
- *
6
- * Created on March 15, 2020
7
- * @author Ralph Florent <ralflornt@gmail.com>
8
- */
9
- const models_1 = require("../models");
10
- const constants_1 = require("../core/constants");
11
- const index_1 = require("./index");
12
- /**
13
- * Represents a `Nama` validator to help the nama parser
14
- * @class
15
- * @implements {Validator}
16
- */
17
- class NamaValidator {
18
- constructor() {
19
- this.type = index_1.ValidatorType.NAMA;
20
- }
21
- /**
22
- * Validates the content of a JSON-formatted names
23
- * @param {string} value data to validate
24
- */
25
- validate(value) {
26
- const entries = Object.entries(value);
27
- if (entries.length < constants_1.MIN_NUMBER_NAME_PART && entries.length > constants_1.MAX_NUMBER_NAME_PART)
28
- throw new index_1.ValidationError('incomplete JSON object', 'Nama');
29
- const validators = {
30
- [models_1.Namon.PREFIX]: new index_1.PrefixValidator(),
31
- [models_1.Namon.FIRST_NAME]: new index_1.FirstnameValidator(),
32
- [models_1.Namon.MIDDLE_NAME]: new index_1.MiddlenameValidator(),
33
- [models_1.Namon.LAST_NAME]: new index_1.LastnameValidator(),
34
- [models_1.Namon.SUFFIX]: new index_1.SuffixValidator(),
35
- };
36
- for (const entry of entries) {
37
- const k = entry[0];
38
- const v = entry[1];
39
- validators[k].validate(v);
40
- }
41
- }
42
- }
43
- exports.default = NamaValidator;
44
- //# sourceMappingURL=nama.validator.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"nama.validator.js","sourceRoot":"","sources":["../../../src/validators/nama.validator.ts"],"names":[],"mappings":";;AAAA;;;;;GAKG;AACH,sCAAwC;AACxC,iDAA+E;AAC/E,mCASiB;AAEjB;;;;GAIG;AACH,MAAqB,aAAa;IAAlC;QACa,SAAI,GAAkB,qBAAa,CAAC,IAAI,CAAC;IAwBtD,CAAC;IAvBG;;;OAGG;IACH,QAAQ,CAAC,KAAW;QAEhB,MAAM,OAAO,GAAG,MAAM,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC;QACtC,IAAI,OAAO,CAAC,MAAM,GAAG,gCAAoB,IAAI,OAAO,CAAC,MAAM,GAAG,gCAAoB;YAC9E,MAAM,IAAI,uBAAe,CAAC,wBAAwB,EAAE,MAAM,CAAC,CAAA;QAE/D,MAAM,UAAU,GAAG;YACf,CAAC,cAAK,CAAC,MAAM,CAAC,EAAE,IAAI,uBAAe,EAAE;YACrC,CAAC,cAAK,CAAC,UAAU,CAAC,EAAE,IAAI,0BAAkB,EAAE;YAC5C,CAAC,cAAK,CAAC,WAAW,CAAC,EAAE,IAAI,2BAAmB,EAAE;YAC9C,CAAC,cAAK,CAAC,SAAS,CAAC,EAAE,IAAI,yBAAiB,EAAE;YAC1C,CAAC,cAAK,CAAC,MAAM,CAAC,EAAE,IAAI,uBAAe,EAAE;SACxC,CAAC;QACF,KAAK,MAAM,KAAK,IAAI,OAAO,EAAE;YACzB,MAAM,CAAC,GAAG,KAAK,CAAC,CAAC,CAAe,CAAC;YACjC,MAAM,CAAC,GAAG,KAAK,CAAC,CAAC,CAAW,CAAC;YAC7B,UAAU,CAAC,CAAC,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC;SAC7B;IACL,CAAC;CACJ;AAzBD,gCAyBC"}
@@ -1,20 +0,0 @@
1
- /**
2
- * Namon validator
3
- *
4
- * Created on March 15, 2020
5
- * @author Ralph Florent <ralflornt@gmail.com>
6
- */
7
- import { Validator, ValidatorType } from './index';
8
- /**
9
- * Represents a namon validator to help to parse single pieces of string
10
- * @class
11
- * @implements {Validator}
12
- */
13
- export default class NamonValidator implements Validator<string> {
14
- readonly type: ValidatorType;
15
- /**
16
- * Validates the content of a name
17
- * @param {string} value data to validate
18
- */
19
- validate(value: string): void;
20
- }
@@ -1,29 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- /**
4
- * Namon validator
5
- *
6
- * Created on March 15, 2020
7
- * @author Ralph Florent <ralflornt@gmail.com>
8
- */
9
- const index_1 = require("./index");
10
- /**
11
- * Represents a namon validator to help to parse single pieces of string
12
- * @class
13
- * @implements {Validator}
14
- */
15
- class NamonValidator {
16
- constructor() {
17
- this.type = index_1.ValidatorType.NAMON;
18
- }
19
- /**
20
- * Validates the content of a name
21
- * @param {string} value data to validate
22
- */
23
- validate(value) {
24
- if (!index_1.ValidationRule.namon.test(value))
25
- throw new index_1.ValidationError(`invalid string content '${value}'`, 'Name');
26
- }
27
- }
28
- exports.default = NamonValidator;
29
- //# sourceMappingURL=namon.validator.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"namon.validator.js","sourceRoot":"","sources":["../../../src/validators/namon.validator.ts"],"names":[],"mappings":";;AAAA;;;;;GAKG;AACH,mCAAoF;AAEpF;;;;GAIG;AACH,MAAqB,cAAc;IAAnC;QACa,SAAI,GAAkB,qBAAa,CAAC,KAAK,CAAC;IASvD,CAAC;IARG;;;OAGG;IACH,QAAQ,CAAC,KAAa;QAClB,IAAI,CAAC,sBAAc,CAAC,KAAK,CAAC,IAAI,CAAC,KAAK,CAAC;YACjC,MAAM,IAAI,uBAAe,CAAC,2BAA2B,KAAK,GAAG,EAAE,MAAM,CAAC,CAAC;IAC/E,CAAC;CACJ;AAVD,iCAUC"}
@@ -1,14 +0,0 @@
1
- import { Validator, ValidatorType } from './index';
2
- /**
3
- * Represents a prefix validator
4
- * @class
5
- * @implements {Validator}
6
- */
7
- export default class PrefixValidator implements Validator<string> {
8
- readonly type: ValidatorType;
9
- /**
10
- * Validates the content of a prefix name
11
- * @param {string} value data to validate
12
- */
13
- validate(value: string): void;
14
- }