valgen 5.18.2 → 5.19.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 (208) hide show
  1. package/{types/constants.d.ts → constants.d.ts} +1 -0
  2. package/{esm/constants.js → constants.js} +1 -0
  3. package/{esm/core → core}/context.js +12 -2
  4. package/{esm/core → core}/validation-error.js +1 -1
  5. package/{types/index.d.ts → index.d.ts} +63 -59
  6. package/{esm/index.js → index.js} +10 -1
  7. package/package.json +9 -25
  8. package/{types/rules → rules}/type-rules/is-date.d.ts +6 -6
  9. package/{esm/rules → rules}/type-rules/is-date.js +21 -10
  10. package/CHANGELOG.md +0 -384
  11. package/cjs/constants.js +0 -7
  12. package/cjs/core/constants.js +0 -5
  13. package/cjs/core/context.js +0 -74
  14. package/cjs/core/index.js +0 -9
  15. package/cjs/core/types.js +0 -2
  16. package/cjs/core/utilities.js +0 -30
  17. package/cjs/core/validation-error.js +0 -12
  18. package/cjs/core/validator.js +0 -71
  19. package/cjs/factories.js +0 -4
  20. package/cjs/helpers/object.utils.js +0 -18
  21. package/cjs/helpers/omit-undefined.js +0 -14
  22. package/cjs/helpers/string.utils.js +0 -6
  23. package/cjs/index.js +0 -129
  24. package/cjs/package.json +0 -3
  25. package/cjs/rules/format-rules/is-alpha.js +0 -30
  26. package/cjs/rules/format-rules/is-ascii.js +0 -17
  27. package/cjs/rules/format-rules/is-base64.js +0 -18
  28. package/cjs/rules/format-rules/is-btc-address.js +0 -18
  29. package/cjs/rules/format-rules/is-credit-card.js +0 -19
  30. package/cjs/rules/format-rules/is-decimal.js +0 -19
  31. package/cjs/rules/format-rules/is-ean.js +0 -17
  32. package/cjs/rules/format-rules/is-email.js +0 -66
  33. package/cjs/rules/format-rules/is-eth-address.js +0 -18
  34. package/cjs/rules/format-rules/is-fqdn.js +0 -21
  35. package/cjs/rules/format-rules/is-hash.js +0 -18
  36. package/cjs/rules/format-rules/is-hex-color.js +0 -18
  37. package/cjs/rules/format-rules/is-hex.js +0 -18
  38. package/cjs/rules/format-rules/is-iban.js +0 -29
  39. package/cjs/rules/format-rules/is-ip.js +0 -35
  40. package/cjs/rules/format-rules/is-issn.js +0 -21
  41. package/cjs/rules/format-rules/is-jwt.js +0 -17
  42. package/cjs/rules/format-rules/is-lowercase.js +0 -31
  43. package/cjs/rules/format-rules/is-mac-address.js +0 -24
  44. package/cjs/rules/format-rules/is-mobile-phone.js +0 -22
  45. package/cjs/rules/format-rules/is-object-id.js +0 -28
  46. package/cjs/rules/format-rules/is-passport-number.js +0 -19
  47. package/cjs/rules/format-rules/is-port.js +0 -22
  48. package/cjs/rules/format-rules/is-time.js +0 -51
  49. package/cjs/rules/format-rules/is-url.js +0 -20
  50. package/cjs/rules/format-rules/is-uuid.js +0 -20
  51. package/cjs/rules/format-rules/is-vat-number.js +0 -18
  52. package/cjs/rules/format-rules/matches.js +0 -22
  53. package/cjs/rules/index.js +0 -56
  54. package/cjs/rules/logical-rules/is-defined.js +0 -15
  55. package/cjs/rules/logical-rules/is-empty.js +0 -110
  56. package/cjs/rules/logical-rules/is-equal.js +0 -32
  57. package/cjs/rules/logical-rules/range.js +0 -175
  58. package/cjs/rules/type-rules/is-any.js +0 -10
  59. package/cjs/rules/type-rules/is-array.js +0 -45
  60. package/cjs/rules/type-rules/is-bigint.js +0 -21
  61. package/cjs/rules/type-rules/is-boolean.js +0 -31
  62. package/cjs/rules/type-rules/is-date.js +0 -180
  63. package/cjs/rules/type-rules/is-enum.js +0 -31
  64. package/cjs/rules/type-rules/is-integer.js +0 -30
  65. package/cjs/rules/type-rules/is-null.js +0 -54
  66. package/cjs/rules/type-rules/is-number.js +0 -27
  67. package/cjs/rules/type-rules/is-object.js +0 -113
  68. package/cjs/rules/type-rules/is-record.js +0 -42
  69. package/cjs/rules/type-rules/is-string.js +0 -81
  70. package/cjs/rules/type-rules/is-tuple.js +0 -38
  71. package/cjs/rules/type-rules/is-undefined.js +0 -17
  72. package/cjs/rules/utility-rules/all-of.js +0 -20
  73. package/cjs/rules/utility-rules/exists.js +0 -18
  74. package/cjs/rules/utility-rules/get-length.js +0 -29
  75. package/cjs/rules/utility-rules/one-of.js +0 -59
  76. package/cjs/rules/utility-rules/optional.js +0 -15
  77. package/cjs/rules/utility-rules/pipe.js +0 -28
  78. package/cjs/rules/utility-rules/required.js +0 -19
  79. package/cjs/tsconfig-build-cjs.tsbuildinfo +0 -1
  80. package/esm/package.json +0 -3
  81. package/esm/tsconfig-build-esm.tsbuildinfo +0 -1
  82. package/types/index.d.cts +0 -65
  83. /package/{types/core → core}/constants.d.ts +0 -0
  84. /package/{esm/core → core}/constants.js +0 -0
  85. /package/{types/core → core}/context.d.ts +0 -0
  86. /package/{types/core → core}/index.d.ts +0 -0
  87. /package/{esm/core → core}/index.js +0 -0
  88. /package/{types/core → core}/types.d.ts +0 -0
  89. /package/{esm/core → core}/types.js +0 -0
  90. /package/{types/core → core}/utilities.d.ts +0 -0
  91. /package/{esm/core → core}/utilities.js +0 -0
  92. /package/{types/core → core}/validation-error.d.ts +0 -0
  93. /package/{types/core → core}/validator.d.ts +0 -0
  94. /package/{esm/core → core}/validator.js +0 -0
  95. /package/{types/factories.d.ts → factories.d.ts} +0 -0
  96. /package/{esm/factories.js → factories.js} +0 -0
  97. /package/{types/helpers → helpers}/object.utils.d.ts +0 -0
  98. /package/{esm/helpers → helpers}/object.utils.js +0 -0
  99. /package/{types/helpers → helpers}/omit-undefined.d.ts +0 -0
  100. /package/{esm/helpers → helpers}/omit-undefined.js +0 -0
  101. /package/{types/helpers → helpers}/string.utils.d.ts +0 -0
  102. /package/{esm/helpers → helpers}/string.utils.js +0 -0
  103. /package/{types/rules → rules}/format-rules/is-alpha.d.ts +0 -0
  104. /package/{esm/rules → rules}/format-rules/is-alpha.js +0 -0
  105. /package/{types/rules → rules}/format-rules/is-ascii.d.ts +0 -0
  106. /package/{esm/rules → rules}/format-rules/is-ascii.js +0 -0
  107. /package/{types/rules → rules}/format-rules/is-base64.d.ts +0 -0
  108. /package/{esm/rules → rules}/format-rules/is-base64.js +0 -0
  109. /package/{types/rules → rules}/format-rules/is-btc-address.d.ts +0 -0
  110. /package/{esm/rules → rules}/format-rules/is-btc-address.js +0 -0
  111. /package/{types/rules → rules}/format-rules/is-credit-card.d.ts +0 -0
  112. /package/{esm/rules → rules}/format-rules/is-credit-card.js +0 -0
  113. /package/{types/rules → rules}/format-rules/is-decimal.d.ts +0 -0
  114. /package/{esm/rules → rules}/format-rules/is-decimal.js +0 -0
  115. /package/{types/rules → rules}/format-rules/is-ean.d.ts +0 -0
  116. /package/{esm/rules → rules}/format-rules/is-ean.js +0 -0
  117. /package/{types/rules → rules}/format-rules/is-email.d.ts +0 -0
  118. /package/{esm/rules → rules}/format-rules/is-email.js +0 -0
  119. /package/{types/rules → rules}/format-rules/is-eth-address.d.ts +0 -0
  120. /package/{esm/rules → rules}/format-rules/is-eth-address.js +0 -0
  121. /package/{types/rules → rules}/format-rules/is-fqdn.d.ts +0 -0
  122. /package/{esm/rules → rules}/format-rules/is-fqdn.js +0 -0
  123. /package/{types/rules → rules}/format-rules/is-hash.d.ts +0 -0
  124. /package/{esm/rules → rules}/format-rules/is-hash.js +0 -0
  125. /package/{types/rules → rules}/format-rules/is-hex-color.d.ts +0 -0
  126. /package/{esm/rules → rules}/format-rules/is-hex-color.js +0 -0
  127. /package/{types/rules → rules}/format-rules/is-hex.d.ts +0 -0
  128. /package/{esm/rules → rules}/format-rules/is-hex.js +0 -0
  129. /package/{types/rules → rules}/format-rules/is-iban.d.ts +0 -0
  130. /package/{esm/rules → rules}/format-rules/is-iban.js +0 -0
  131. /package/{types/rules → rules}/format-rules/is-ip.d.ts +0 -0
  132. /package/{esm/rules → rules}/format-rules/is-ip.js +0 -0
  133. /package/{types/rules → rules}/format-rules/is-issn.d.ts +0 -0
  134. /package/{esm/rules → rules}/format-rules/is-issn.js +0 -0
  135. /package/{types/rules → rules}/format-rules/is-jwt.d.ts +0 -0
  136. /package/{esm/rules → rules}/format-rules/is-jwt.js +0 -0
  137. /package/{types/rules → rules}/format-rules/is-lowercase.d.ts +0 -0
  138. /package/{esm/rules → rules}/format-rules/is-lowercase.js +0 -0
  139. /package/{types/rules → rules}/format-rules/is-mac-address.d.ts +0 -0
  140. /package/{esm/rules → rules}/format-rules/is-mac-address.js +0 -0
  141. /package/{types/rules → rules}/format-rules/is-mobile-phone.d.ts +0 -0
  142. /package/{esm/rules → rules}/format-rules/is-mobile-phone.js +0 -0
  143. /package/{types/rules → rules}/format-rules/is-object-id.d.ts +0 -0
  144. /package/{esm/rules → rules}/format-rules/is-object-id.js +0 -0
  145. /package/{types/rules → rules}/format-rules/is-passport-number.d.ts +0 -0
  146. /package/{esm/rules → rules}/format-rules/is-passport-number.js +0 -0
  147. /package/{types/rules → rules}/format-rules/is-port.d.ts +0 -0
  148. /package/{esm/rules → rules}/format-rules/is-port.js +0 -0
  149. /package/{types/rules → rules}/format-rules/is-time.d.ts +0 -0
  150. /package/{esm/rules → rules}/format-rules/is-time.js +0 -0
  151. /package/{types/rules → rules}/format-rules/is-url.d.ts +0 -0
  152. /package/{esm/rules → rules}/format-rules/is-url.js +0 -0
  153. /package/{types/rules → rules}/format-rules/is-uuid.d.ts +0 -0
  154. /package/{esm/rules → rules}/format-rules/is-uuid.js +0 -0
  155. /package/{types/rules → rules}/format-rules/is-vat-number.d.ts +0 -0
  156. /package/{esm/rules → rules}/format-rules/is-vat-number.js +0 -0
  157. /package/{types/rules → rules}/format-rules/matches.d.ts +0 -0
  158. /package/{esm/rules → rules}/format-rules/matches.js +0 -0
  159. /package/{types/rules → rules}/index.d.ts +0 -0
  160. /package/{esm/rules → rules}/index.js +0 -0
  161. /package/{types/rules → rules}/logical-rules/is-defined.d.ts +0 -0
  162. /package/{esm/rules → rules}/logical-rules/is-defined.js +0 -0
  163. /package/{types/rules → rules}/logical-rules/is-empty.d.ts +0 -0
  164. /package/{esm/rules → rules}/logical-rules/is-empty.js +0 -0
  165. /package/{types/rules → rules}/logical-rules/is-equal.d.ts +0 -0
  166. /package/{esm/rules → rules}/logical-rules/is-equal.js +0 -0
  167. /package/{types/rules → rules}/logical-rules/range.d.ts +0 -0
  168. /package/{esm/rules → rules}/logical-rules/range.js +0 -0
  169. /package/{types/rules → rules}/type-rules/is-any.d.ts +0 -0
  170. /package/{esm/rules → rules}/type-rules/is-any.js +0 -0
  171. /package/{types/rules → rules}/type-rules/is-array.d.ts +0 -0
  172. /package/{esm/rules → rules}/type-rules/is-array.js +0 -0
  173. /package/{types/rules → rules}/type-rules/is-bigint.d.ts +0 -0
  174. /package/{esm/rules → rules}/type-rules/is-bigint.js +0 -0
  175. /package/{types/rules → rules}/type-rules/is-boolean.d.ts +0 -0
  176. /package/{esm/rules → rules}/type-rules/is-boolean.js +0 -0
  177. /package/{types/rules → rules}/type-rules/is-enum.d.ts +0 -0
  178. /package/{esm/rules → rules}/type-rules/is-enum.js +0 -0
  179. /package/{types/rules → rules}/type-rules/is-integer.d.ts +0 -0
  180. /package/{esm/rules → rules}/type-rules/is-integer.js +0 -0
  181. /package/{types/rules → rules}/type-rules/is-null.d.ts +0 -0
  182. /package/{esm/rules → rules}/type-rules/is-null.js +0 -0
  183. /package/{types/rules → rules}/type-rules/is-number.d.ts +0 -0
  184. /package/{esm/rules → rules}/type-rules/is-number.js +0 -0
  185. /package/{types/rules → rules}/type-rules/is-object.d.ts +0 -0
  186. /package/{esm/rules → rules}/type-rules/is-object.js +0 -0
  187. /package/{types/rules → rules}/type-rules/is-record.d.ts +0 -0
  188. /package/{esm/rules → rules}/type-rules/is-record.js +0 -0
  189. /package/{types/rules → rules}/type-rules/is-string.d.ts +0 -0
  190. /package/{esm/rules → rules}/type-rules/is-string.js +0 -0
  191. /package/{types/rules → rules}/type-rules/is-tuple.d.ts +0 -0
  192. /package/{esm/rules → rules}/type-rules/is-tuple.js +0 -0
  193. /package/{types/rules → rules}/type-rules/is-undefined.d.ts +0 -0
  194. /package/{esm/rules → rules}/type-rules/is-undefined.js +0 -0
  195. /package/{types/rules → rules}/utility-rules/all-of.d.ts +0 -0
  196. /package/{esm/rules → rules}/utility-rules/all-of.js +0 -0
  197. /package/{types/rules → rules}/utility-rules/exists.d.ts +0 -0
  198. /package/{esm/rules → rules}/utility-rules/exists.js +0 -0
  199. /package/{types/rules → rules}/utility-rules/get-length.d.ts +0 -0
  200. /package/{esm/rules → rules}/utility-rules/get-length.js +0 -0
  201. /package/{types/rules → rules}/utility-rules/one-of.d.ts +0 -0
  202. /package/{esm/rules → rules}/utility-rules/one-of.js +0 -0
  203. /package/{types/rules → rules}/utility-rules/optional.d.ts +0 -0
  204. /package/{esm/rules → rules}/utility-rules/optional.js +0 -0
  205. /package/{types/rules → rules}/utility-rules/pipe.d.ts +0 -0
  206. /package/{esm/rules → rules}/utility-rules/pipe.js +0 -0
  207. /package/{types/rules → rules}/utility-rules/required.d.ts +0 -0
  208. /package/{esm/rules → rules}/utility-rules/required.js +0 -0
package/cjs/index.js DELETED
@@ -1,129 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.isUUID4 = exports.isUUID3 = exports.isUUID2 = exports.isUUID1 = exports.isUUID = exports.isURL = exports.isUppercase = exports.isUndefined = exports.isTime = exports.isSWIFT = exports.isString = exports.isPort = exports.isObjectId = exports.isObject = exports.isNumber = exports.isNullish = exports.isNull = exports.isNotNullish = exports.isNotNull = exports.isNotEmpty = exports.isMobilePhone = exports.isMACAddress = exports.isLowercase = exports.isJWT = exports.isISSN = exports.isIPRange = exports.isIP = exports.isInteger = exports.isIBAN = exports.isHexColor = exports.isHex = exports.isFQDN = exports.isETHAddress = exports.isEmpty = exports.isEmail = exports.isEAN = exports.isDefined = exports.isDecimal = exports.isDateString = exports.isDate = exports.isCreditCard = exports.isBtcAddress = exports.isBoolean = exports.isBigint = exports.isBase64 = exports.isAscii = exports.isArray = exports.isAny = exports.isAlphanumeric = exports.isAlpha = void 0;
4
- exports.vg = exports.toTime = exports.toString = exports.toNumber = exports.toInteger = exports.toDateString = exports.toDate = exports.toBoolean = exports.toBigint = exports.toArray = exports.isUUID5 = void 0;
5
- const tslib_1 = require("tslib");
6
- const vg = tslib_1.__importStar(require("./rules/index.js"));
7
- exports.vg = vg;
8
- tslib_1.__exportStar(require("./constants.js"), exports);
9
- tslib_1.__exportStar(require("./core/index.js"), exports);
10
- const isAlpha = vg.isAlpha();
11
- exports.isAlpha = isAlpha;
12
- const isAlphanumeric = vg.isAlphanumeric();
13
- exports.isAlphanumeric = isAlphanumeric;
14
- const isAny = vg.isAny();
15
- exports.isAny = isAny;
16
- const isArray = vg.isArray();
17
- exports.isArray = isArray;
18
- const isAscii = vg.isAscii();
19
- exports.isAscii = isAscii;
20
- const isBase64 = vg.isBase64();
21
- exports.isBase64 = isBase64;
22
- const isBigint = vg.isBigint();
23
- exports.isBigint = isBigint;
24
- const isBoolean = vg.isBoolean();
25
- exports.isBoolean = isBoolean;
26
- const isBtcAddress = vg.isBtcAddress();
27
- exports.isBtcAddress = isBtcAddress;
28
- const isCreditCard = vg.isCreditCard();
29
- exports.isCreditCard = isCreditCard;
30
- const isDate = vg.isDate();
31
- exports.isDate = isDate;
32
- const isDateString = vg.isDateString();
33
- exports.isDateString = isDateString;
34
- const isDecimal = vg.isDecimal();
35
- exports.isDecimal = isDecimal;
36
- const isDefined = vg.isDefined();
37
- exports.isDefined = isDefined;
38
- const isEAN = vg.isEAN();
39
- exports.isEAN = isEAN;
40
- const isEmail = vg.isEmail();
41
- exports.isEmail = isEmail;
42
- const isEmpty = vg.isEmpty();
43
- exports.isEmpty = isEmpty;
44
- const isETHAddress = vg.isETHAddress();
45
- exports.isETHAddress = isETHAddress;
46
- const isFQDN = vg.isFQDN();
47
- exports.isFQDN = isFQDN;
48
- const isHex = vg.isHex();
49
- exports.isHex = isHex;
50
- const isHexColor = vg.isHexColor();
51
- exports.isHexColor = isHexColor;
52
- const isIBAN = vg.isIBAN();
53
- exports.isIBAN = isIBAN;
54
- const isInteger = vg.isInteger();
55
- exports.isInteger = isInteger;
56
- const isIP = vg.isIP();
57
- exports.isIP = isIP;
58
- const isIPRange = vg.isIPRange();
59
- exports.isIPRange = isIPRange;
60
- const isISSN = vg.isISSN();
61
- exports.isISSN = isISSN;
62
- const isJWT = vg.isJWT();
63
- exports.isJWT = isJWT;
64
- const isLowercase = vg.isLowercase();
65
- exports.isLowercase = isLowercase;
66
- const isMACAddress = vg.isMACAddress();
67
- exports.isMACAddress = isMACAddress;
68
- const isMobilePhone = vg.isMobilePhone();
69
- exports.isMobilePhone = isMobilePhone;
70
- const isNotEmpty = vg.isNotEmpty();
71
- exports.isNotEmpty = isNotEmpty;
72
- const isNotNull = vg.isNotNull();
73
- exports.isNotNull = isNotNull;
74
- const isNotNullish = vg.isNotNullish();
75
- exports.isNotNullish = isNotNullish;
76
- const isNull = vg.isNull();
77
- exports.isNull = isNull;
78
- const isNullish = vg.isNullish();
79
- exports.isNullish = isNullish;
80
- const isNumber = vg.isNumber();
81
- exports.isNumber = isNumber;
82
- const isObject = vg.isObject();
83
- exports.isObject = isObject;
84
- const isObjectId = vg.isObjectId();
85
- exports.isObjectId = isObjectId;
86
- const isPort = vg.isPort();
87
- exports.isPort = isPort;
88
- const isString = vg.isString();
89
- exports.isString = isString;
90
- const isSWIFT = vg.isSWIFT();
91
- exports.isSWIFT = isSWIFT;
92
- const isTime = vg.isTime();
93
- exports.isTime = isTime;
94
- const isUndefined = vg.isUndefined();
95
- exports.isUndefined = isUndefined;
96
- const isUppercase = vg.isUppercase();
97
- exports.isUppercase = isUppercase;
98
- const isURL = vg.isURL();
99
- exports.isURL = isURL;
100
- const isUUID = vg.isUUID();
101
- exports.isUUID = isUUID;
102
- const isUUID1 = vg.isUUID(1);
103
- exports.isUUID1 = isUUID1;
104
- const isUUID2 = vg.isUUID(2);
105
- exports.isUUID2 = isUUID2;
106
- const isUUID3 = vg.isUUID(3);
107
- exports.isUUID3 = isUUID3;
108
- const isUUID4 = vg.isUUID(4);
109
- exports.isUUID4 = isUUID4;
110
- const isUUID5 = vg.isUUID(5);
111
- exports.isUUID5 = isUUID5;
112
- const toArray = vg.isArray(isAny, { coerce: true });
113
- exports.toArray = toArray;
114
- const toBigint = vg.isBigint({ coerce: true });
115
- exports.toBigint = toBigint;
116
- const toBoolean = vg.isBoolean({ coerce: true });
117
- exports.toBoolean = toBoolean;
118
- const toDate = vg.isDate({ coerce: true });
119
- exports.toDate = toDate;
120
- const toDateString = vg.isDateString({ coerce: true, precisionMin: 'day' });
121
- exports.toDateString = toDateString;
122
- const toInteger = vg.isInteger({ coerce: true });
123
- exports.toInteger = toInteger;
124
- const toNumber = vg.isNumber({ coerce: true });
125
- exports.toNumber = toNumber;
126
- const toString = vg.isString({ coerce: true });
127
- exports.toString = toString;
128
- const toTime = vg.isTime({ coerce: true });
129
- exports.toTime = toTime;
package/cjs/package.json DELETED
@@ -1,3 +0,0 @@
1
- {
2
- "type": "commonjs"
3
- }
@@ -1,30 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.isAlpha = isAlpha;
4
- exports.isAlphanumeric = isAlphanumeric;
5
- const tslib_1 = require("tslib");
6
- const validator_1 = tslib_1.__importDefault(require("@browsery/validator"));
7
- const index_js_1 = require("../../core/index.js");
8
- /**
9
- * Check if the string contains only letters (a-zA-Z).
10
- * @validator isAlpha
11
- */
12
- function isAlpha(options) {
13
- return (0, index_js_1.validator)('isLowercase', (input, context, _this) => {
14
- if (typeof input === 'string' && validator_1.default.isAlpha(input))
15
- return input;
16
- context.fail(_this, `"Value must be an alpha string`, input);
17
- }, options);
18
- }
19
- /**
20
- * Check if the string contains only letters and numbers.
21
- * @validator isAlphanumeric
22
- */
23
- function isAlphanumeric(options) {
24
- return (0, index_js_1.validator)('isAlphanumeric', (input, context, _this) => {
25
- if (typeof input === 'string' && validator_1.default.isAlphanumeric(input)) {
26
- return input;
27
- }
28
- context.fail(_this, `"Value must be an alphanumeric string`, input);
29
- }, options);
30
- }
@@ -1,17 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.isAscii = isAscii;
4
- const tslib_1 = require("tslib");
5
- const validator_1 = tslib_1.__importDefault(require("@browsery/validator"));
6
- const index_js_1 = require("../../core/index.js");
7
- /**
8
- * Check if the string contains ASCII chars only.
9
- * @validator isAscii
10
- */
11
- function isAscii(options) {
12
- return (0, index_js_1.validator)('isAscii', (input, context, _this) => {
13
- if (typeof input === 'string' && validator_1.default.isAscii(input))
14
- return input;
15
- context.fail(_this, `Value must be an ascii string`, input);
16
- }, options);
17
- }
@@ -1,18 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.isBase64 = isBase64;
4
- const tslib_1 = require("tslib");
5
- const validator_1 = tslib_1.__importDefault(require("@browsery/validator"));
6
- const index_js_1 = require("../../core/index.js");
7
- /**
8
- * Validates if value is a "Base64" string.
9
- * @validator isBase64
10
- */
11
- function isBase64(options) {
12
- return (0, index_js_1.validator)('isBase64', (input, context, _this) => {
13
- if (typeof input === 'string' && validator_1.default.isBase64(input, options)) {
14
- return input;
15
- }
16
- context.fail(_this, `"Value must be a Base64 string`, input);
17
- }, options);
18
- }
@@ -1,18 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.isBtcAddress = isBtcAddress;
4
- const tslib_1 = require("tslib");
5
- const validator_1 = tslib_1.__importDefault(require("@browsery/validator"));
6
- const index_js_1 = require("../../core/index.js");
7
- /**
8
- * Validates if value is a BTC address.
9
- * @validator isBtcAddress
10
- */
11
- function isBtcAddress(options) {
12
- return (0, index_js_1.validator)('isBtcAddress', (input, context, _this) => {
13
- if (typeof input === 'string' && validator_1.default.isBtcAddress(input)) {
14
- return input;
15
- }
16
- context.fail(_this, `Value must be a valid BTC address`, input);
17
- }, options);
18
- }
@@ -1,19 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.isCreditCard = isCreditCard;
4
- const tslib_1 = require("tslib");
5
- const validator_1 = tslib_1.__importDefault(require("@browsery/validator"));
6
- const index_js_1 = require("../../core/index.js");
7
- /**
8
- * Validates if value is a credit card number
9
- * @validator isCreditCard
10
- */
11
- function isCreditCard(options) {
12
- return (0, index_js_1.validator)('isCreditCard', (input, context, _this) => {
13
- if (typeof input === 'string' &&
14
- validator_1.default.isCreditCard(input, options)) {
15
- return input;
16
- }
17
- context.fail(_this, `Value must be a valid Credit Card number`, input);
18
- }, options);
19
- }
@@ -1,19 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.isDecimal = isDecimal;
4
- const tslib_1 = require("tslib");
5
- const validator_1 = tslib_1.__importDefault(require("@browsery/validator"));
6
- const index_js_1 = require("../../core/index.js");
7
- /**
8
- * Check if the string represents a decimal number,
9
- * such as `0.1`, `.3`, `1.1`, `1.00003`, `4.0` etc.
10
- * @validator isDecimal
11
- */
12
- function isDecimal(options) {
13
- return (0, index_js_1.validator)('isDecimal', (input, context, _this) => {
14
- if (typeof input === 'string' && validator_1.default.isDecimal(input)) {
15
- return input;
16
- }
17
- context.fail(_this, `Value must be a decimal number string`, input);
18
- }, options);
19
- }
@@ -1,17 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.isEAN = isEAN;
4
- const tslib_1 = require("tslib");
5
- const validator_1 = tslib_1.__importDefault(require("@browsery/validator"));
6
- const index_js_1 = require("../../core/index.js");
7
- /**
8
- * Validates if value is an EAN (European Article Number)
9
- * @validator isEAN
10
- */
11
- function isEAN(options) {
12
- return (0, index_js_1.validator)('isEAN', (input, context, _this) => {
13
- if (typeof input === 'string' && validator_1.default.isEAN(input))
14
- return input;
15
- context.fail(_this, `Value must be a valid EAN (European Article Number)`, input);
16
- }, options);
17
- }
@@ -1,66 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.isEmail = isEmail;
4
- const tslib_1 = require("tslib");
5
- const validator_1 = tslib_1.__importDefault(require("@browsery/validator"));
6
- const index_js_1 = require("../../core/index.js");
7
- /**
8
- * Validates if value is a valid Email
9
- * @validator isEmail
10
- */
11
- function isEmail(options) {
12
- const emailOptions = {
13
- allow_display_name: true,
14
- allow_utf8_local_part: options?.utf8LocalPart,
15
- ignore_max_length: true,
16
- allow_ip_domain: options?.allowIpDomain,
17
- };
18
- return (0, index_js_1.validator)('isEmail', (input, context, _this) => {
19
- if (typeof input === 'string' &&
20
- validator_1.default.isEmail(input, emailOptions)) {
21
- if (options?.requireDisplayName) {
22
- if (!validator_1.default.isEmail(input, {
23
- ...emailOptions,
24
- require_display_name: true,
25
- })) {
26
- context.fail(_this, `Display name for the email is required. Etc. ( Name <me@tempuri.org> ) `, input);
27
- return;
28
- }
29
- }
30
- else if (!options?.allowDisplayName &&
31
- !validator_1.default.isEmail(input, {
32
- ...emailOptions,
33
- allow_display_name: false,
34
- })) {
35
- context.fail(_this, `Display name in email is not allowed`, input);
36
- return;
37
- }
38
- if (options?.hostBlacklist &&
39
- !validator_1.default.isEmail(input, {
40
- ...emailOptions,
41
- host_blacklist: options.hostBlacklist,
42
- })) {
43
- context.fail(_this, `Email "{{value}}" is in black-list`, input);
44
- return;
45
- }
46
- if (options?.hostWhitelist &&
47
- !validator_1.default.isEmail(input, {
48
- ...emailOptions,
49
- host_whitelist: options.hostWhitelist,
50
- })) {
51
- context.fail(_this, `Email "{{value}}" is in not white-list`, input);
52
- return;
53
- }
54
- if (options?.blacklistedChars &&
55
- !validator_1.default.isEmail(input, {
56
- ...emailOptions,
57
- blacklisted_chars: options.blacklistedChars,
58
- })) {
59
- context.fail(_this, `Black listed characters (${options.blacklistedChars}) found in name part`, input);
60
- return;
61
- }
62
- return input;
63
- }
64
- context.fail(_this, `Value must much required e-mail format`, input);
65
- }, options);
66
- }
@@ -1,18 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.isETHAddress = isETHAddress;
4
- const tslib_1 = require("tslib");
5
- const validator_1 = tslib_1.__importDefault(require("@browsery/validator"));
6
- const index_js_1 = require("../../core/index.js");
7
- /**
8
- * Validates if value is a ETH (Ethereum) address.
9
- * @validator isETHAddress
10
- */
11
- function isETHAddress(options) {
12
- return (0, index_js_1.validator)('isETHAddress', (input, context, _this) => {
13
- if (typeof input === 'string' && validator_1.default.isEthereumAddress(input)) {
14
- return input;
15
- }
16
- context.fail(_this, `Value must be valid ETH (Ethereum) address`, input);
17
- }, options);
18
- }
@@ -1,21 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.isFQDN = isFQDN;
4
- const tslib_1 = require("tslib");
5
- const validator_1 = tslib_1.__importDefault(require("@browsery/validator"));
6
- const index_js_1 = require("../../core/index.js");
7
- /**
8
- * Validates if value is an FQDN
9
- * @validator isFQDN
10
- */
11
- function isFQDN(options) {
12
- const opts = {
13
- allow_wildcard: options?.allowWildcard,
14
- };
15
- return (0, index_js_1.validator)('isFQDN', (input, context, _this) => {
16
- if (typeof input === 'string' && validator_1.default.isFQDN(input, opts)) {
17
- return input;
18
- }
19
- context.fail(_this, `Value must be valid FQDN`, input);
20
- }, options);
21
- }
@@ -1,18 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.isHash = isHash;
4
- const tslib_1 = require("tslib");
5
- const validator_1 = tslib_1.__importDefault(require("@browsery/validator"));
6
- const index_js_1 = require("../../core/index.js");
7
- /**
8
- * Validates if value a hash of type algorithm
9
- * @validator isHash
10
- */
11
- function isHash(algorithm, options) {
12
- return (0, index_js_1.validator)('isHash', (input, context, _this) => {
13
- if (typeof input === 'string' && validator_1.default.isHash(input, algorithm)) {
14
- return input;
15
- }
16
- context.fail(_this, `Value must be a valid ${algorithm} hash`, input);
17
- }, options);
18
- }
@@ -1,18 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.isHexColor = isHexColor;
4
- const tslib_1 = require("tslib");
5
- const validator_1 = tslib_1.__importDefault(require("@browsery/validator"));
6
- const index_js_1 = require("../../core/index.js");
7
- /**
8
- * Validates if value is a Hex Color
9
- * @validator isHexColor
10
- */
11
- function isHexColor(options) {
12
- return (0, index_js_1.validator)('isHexColor', (input, context, _this) => {
13
- if (typeof input === 'string' && validator_1.default.isHexColor(input)) {
14
- return input;
15
- }
16
- context.fail(_this, `Value must be a valid Hex Color`, input);
17
- }, options);
18
- }
@@ -1,18 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.isHex = isHex;
4
- const tslib_1 = require("tslib");
5
- const validator_1 = tslib_1.__importDefault(require("@browsery/validator"));
6
- const index_js_1 = require("../../core/index.js");
7
- /**
8
- * Check if the string is a hexadecimal number.
9
- * @validator isHex
10
- */
11
- function isHex(options) {
12
- return (0, index_js_1.validator)('isHex', (input, context, _this) => {
13
- if (typeof input === 'string' && validator_1.default.isHexadecimal(input)) {
14
- return input;
15
- }
16
- context.fail(_this, `Value must be an hexadecimal string`, input);
17
- }, options);
18
- }
@@ -1,29 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.isIBAN = isIBAN;
4
- exports.isSWIFT = isSWIFT;
5
- const tslib_1 = require("tslib");
6
- const validator_1 = tslib_1.__importDefault(require("@browsery/validator"));
7
- const index_js_1 = require("../../core/index.js");
8
- /**
9
- * Validates if value is an IBAN (International Bank Account Number)
10
- * @validator isIBAN
11
- */
12
- function isIBAN(options) {
13
- return (0, index_js_1.validator)('isIBAN', (input, context, _this) => {
14
- if (typeof input === 'string' && validator_1.default.isIBAN(input))
15
- return input;
16
- context.fail(_this, `Value must be a valid IBAN (International Bank Account Number)`, input);
17
- }, options);
18
- }
19
- /**
20
- * Validates if value is a BIC (Bank Identification Code) or SWIFT code
21
- * @validator isSWIFT
22
- */
23
- function isSWIFT(options) {
24
- return (0, index_js_1.validator)('isSWIFT', (input, context, _this) => {
25
- if (typeof input === 'string' && validator_1.default.isBIC(input))
26
- return input;
27
- context.fail(_this, `Value must be a valid a BIC (Bank Identification Code) or SWIFT code`, input);
28
- }, options);
29
- }
@@ -1,35 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.isIP = isIP;
4
- exports.isIPRange = isIPRange;
5
- const tslib_1 = require("tslib");
6
- const validator_1 = tslib_1.__importDefault(require("@browsery/validator"));
7
- const index_js_1 = require("../../core/index.js");
8
- /**
9
- * Validates if value is an IP
10
- * @validator isIP
11
- */
12
- function isIP(version, options) {
13
- return (0, index_js_1.validator)('isIP', (input, context, _this) => {
14
- if (input != null &&
15
- typeof input === 'string' &&
16
- validator_1.default.isIP(input, version)) {
17
- return input;
18
- }
19
- context.fail(_this, `Value must be a valid IP${version ? ' v' + version : ''}`, input);
20
- }, options);
21
- }
22
- /**
23
- * Validates if value is an IP
24
- * @validator isIPRange
25
- */
26
- function isIPRange(version, options) {
27
- return (0, index_js_1.validator)('isIPRange', (input, context, _this) => {
28
- if (input != null &&
29
- typeof input === 'string' &&
30
- validator_1.default.isIPRange(input, version)) {
31
- return input;
32
- }
33
- context.fail(_this, `Value must be a valid IP${version ? ' v' + version : ''} range`, input);
34
- }, options);
35
- }
@@ -1,21 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.isISSN = isISSN;
4
- const tslib_1 = require("tslib");
5
- const validator_1 = tslib_1.__importDefault(require("@browsery/validator"));
6
- const index_js_1 = require("../../core/index.js");
7
- /**
8
- * Validates if value is an ISSN
9
- * @validator isISSN
10
- */
11
- function isISSN(options) {
12
- const opts = {
13
- case_sensitive: options?.caseSensitive,
14
- };
15
- return (0, index_js_1.validator)('isISSN', (input, context, _this) => {
16
- if (typeof input === 'string' && validator_1.default.isISSN(input, opts)) {
17
- return input;
18
- }
19
- context.fail(_this, `Value must be a valid ISSN`, input);
20
- }, options);
21
- }
@@ -1,17 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.isJWT = isJWT;
4
- const tslib_1 = require("tslib");
5
- const validator_1 = tslib_1.__importDefault(require("@browsery/validator"));
6
- const index_js_1 = require("../../core/index.js");
7
- /**
8
- * Validates if value a valid JWT token
9
- * @validator isJWT
10
- */
11
- function isJWT(options) {
12
- return (0, index_js_1.validator)('isJWT', (input, context, _this) => {
13
- if (typeof input === 'string' && validator_1.default.isJWT(input))
14
- return input;
15
- context.fail(_this, `Value must be valid JWT token`, input);
16
- }, options);
17
- }
@@ -1,31 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.isLowercase = isLowercase;
4
- exports.isUppercase = isUppercase;
5
- const tslib_1 = require("tslib");
6
- const validator_1 = tslib_1.__importDefault(require("@browsery/validator"));
7
- const index_js_1 = require("../../core/index.js");
8
- /**
9
- * Validates if value a Lowercase string
10
- * @validator isLowercase
11
- */
12
- function isLowercase(options) {
13
- return (0, index_js_1.validator)('isLowercase', (input, context, _this) => {
14
- if (typeof input === 'string' && validator_1.default.isLowercase(input)) {
15
- return input;
16
- }
17
- context.fail(_this, `Value must be a lowercase string`, input);
18
- }, options);
19
- }
20
- /**
21
- * Validates if value a Uppercase string
22
- * @validator isUppercase
23
- */
24
- function isUppercase(options) {
25
- return (0, index_js_1.validator)('isUppercase', (input, context, _this) => {
26
- if (typeof input === 'string' && validator_1.default.isUppercase(input)) {
27
- return input;
28
- }
29
- context.fail(_this, `Value must be an uppercase string`, input);
30
- }, options);
31
- }
@@ -1,24 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.isMACAddress = isMACAddress;
4
- const tslib_1 = require("tslib");
5
- const validator_1 = tslib_1.__importDefault(require("@browsery/validator"));
6
- const index_js_1 = require("../../core/index.js");
7
- /**
8
- * Validates if value is an MACAddress
9
- * @validator isMACAddress
10
- */
11
- function isMACAddress(options) {
12
- const opts = {
13
- no_separators: options?.noSeparators,
14
- eui: options?.eui,
15
- };
16
- return (0, index_js_1.validator)('isMACAddress', (input, context, _this) => {
17
- if (input != null &&
18
- typeof input === 'string' &&
19
- validator_1.default.isMACAddress(input, opts)) {
20
- return input;
21
- }
22
- context.fail(_this, `Value must be a valid MAC address`, input);
23
- }, options);
24
- }
@@ -1,22 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.isMobilePhone = isMobilePhone;
4
- const tslib_1 = require("tslib");
5
- const validator_1 = tslib_1.__importDefault(require("@browsery/validator"));
6
- const index_js_1 = require("../../core/index.js");
7
- /**
8
- * Validates if value is a valid Email
9
- * @validator isMobilePhone
10
- */
11
- function isMobilePhone(options) {
12
- const opts = {
13
- strictMode: options?.strictMode,
14
- };
15
- return (0, index_js_1.validator)('isMobilePhone', (input, context, _this) => {
16
- if (typeof input === 'string' &&
17
- validator_1.default.isMobilePhone(input, options?.locale, opts)) {
18
- return input;
19
- }
20
- context.fail(_this, `Value must be a valid a Mobile Phone Number`, input);
21
- }, options);
22
- }
@@ -1,28 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.isObjectId = isObjectId;
4
- const tslib_1 = require("tslib");
5
- const validator_1 = tslib_1.__importDefault(require("@browsery/validator"));
6
- const index_js_1 = require("../../core/index.js");
7
- /**
8
- * Validates if value is an "ObjectId".
9
- * @validator isObjectId
10
- */
11
- function isObjectId(options) {
12
- return (0, index_js_1.validator)('isObjectId', (input, context, _this) => {
13
- if (input != null &&
14
- (_isObjectIdValue(input) ||
15
- (typeof input === 'object' &&
16
- typeof input.toHexString === 'function' &&
17
- _isObjectIdValue(input.toHexString())))) {
18
- return input;
19
- }
20
- context.fail(_this, `Value must be a valid ObjectId`, input);
21
- }, options);
22
- }
23
- function _isObjectIdValue(input) {
24
- return ((input instanceof Uint8Array && input.length === 12) ||
25
- (typeof input === 'string' &&
26
- input.length === 24 &&
27
- validator_1.default.isHexadecimal(input)));
28
- }