valgen 5.18.2 → 5.19.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (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/package.json +9 -25
  6. package/{types/rules → rules}/type-rules/is-date.d.ts +1 -0
  7. package/{esm/rules → rules}/type-rules/is-date.js +21 -10
  8. package/CHANGELOG.md +0 -384
  9. package/cjs/constants.js +0 -7
  10. package/cjs/core/constants.js +0 -5
  11. package/cjs/core/context.js +0 -74
  12. package/cjs/core/index.js +0 -9
  13. package/cjs/core/types.js +0 -2
  14. package/cjs/core/utilities.js +0 -30
  15. package/cjs/core/validation-error.js +0 -12
  16. package/cjs/core/validator.js +0 -71
  17. package/cjs/factories.js +0 -4
  18. package/cjs/helpers/object.utils.js +0 -18
  19. package/cjs/helpers/omit-undefined.js +0 -14
  20. package/cjs/helpers/string.utils.js +0 -6
  21. package/cjs/index.js +0 -129
  22. package/cjs/package.json +0 -3
  23. package/cjs/rules/format-rules/is-alpha.js +0 -30
  24. package/cjs/rules/format-rules/is-ascii.js +0 -17
  25. package/cjs/rules/format-rules/is-base64.js +0 -18
  26. package/cjs/rules/format-rules/is-btc-address.js +0 -18
  27. package/cjs/rules/format-rules/is-credit-card.js +0 -19
  28. package/cjs/rules/format-rules/is-decimal.js +0 -19
  29. package/cjs/rules/format-rules/is-ean.js +0 -17
  30. package/cjs/rules/format-rules/is-email.js +0 -66
  31. package/cjs/rules/format-rules/is-eth-address.js +0 -18
  32. package/cjs/rules/format-rules/is-fqdn.js +0 -21
  33. package/cjs/rules/format-rules/is-hash.js +0 -18
  34. package/cjs/rules/format-rules/is-hex-color.js +0 -18
  35. package/cjs/rules/format-rules/is-hex.js +0 -18
  36. package/cjs/rules/format-rules/is-iban.js +0 -29
  37. package/cjs/rules/format-rules/is-ip.js +0 -35
  38. package/cjs/rules/format-rules/is-issn.js +0 -21
  39. package/cjs/rules/format-rules/is-jwt.js +0 -17
  40. package/cjs/rules/format-rules/is-lowercase.js +0 -31
  41. package/cjs/rules/format-rules/is-mac-address.js +0 -24
  42. package/cjs/rules/format-rules/is-mobile-phone.js +0 -22
  43. package/cjs/rules/format-rules/is-object-id.js +0 -28
  44. package/cjs/rules/format-rules/is-passport-number.js +0 -19
  45. package/cjs/rules/format-rules/is-port.js +0 -22
  46. package/cjs/rules/format-rules/is-time.js +0 -51
  47. package/cjs/rules/format-rules/is-url.js +0 -20
  48. package/cjs/rules/format-rules/is-uuid.js +0 -20
  49. package/cjs/rules/format-rules/is-vat-number.js +0 -18
  50. package/cjs/rules/format-rules/matches.js +0 -22
  51. package/cjs/rules/index.js +0 -56
  52. package/cjs/rules/logical-rules/is-defined.js +0 -15
  53. package/cjs/rules/logical-rules/is-empty.js +0 -110
  54. package/cjs/rules/logical-rules/is-equal.js +0 -32
  55. package/cjs/rules/logical-rules/range.js +0 -175
  56. package/cjs/rules/type-rules/is-any.js +0 -10
  57. package/cjs/rules/type-rules/is-array.js +0 -45
  58. package/cjs/rules/type-rules/is-bigint.js +0 -21
  59. package/cjs/rules/type-rules/is-boolean.js +0 -31
  60. package/cjs/rules/type-rules/is-date.js +0 -180
  61. package/cjs/rules/type-rules/is-enum.js +0 -31
  62. package/cjs/rules/type-rules/is-integer.js +0 -30
  63. package/cjs/rules/type-rules/is-null.js +0 -54
  64. package/cjs/rules/type-rules/is-number.js +0 -27
  65. package/cjs/rules/type-rules/is-object.js +0 -113
  66. package/cjs/rules/type-rules/is-record.js +0 -42
  67. package/cjs/rules/type-rules/is-string.js +0 -81
  68. package/cjs/rules/type-rules/is-tuple.js +0 -38
  69. package/cjs/rules/type-rules/is-undefined.js +0 -17
  70. package/cjs/rules/utility-rules/all-of.js +0 -20
  71. package/cjs/rules/utility-rules/exists.js +0 -18
  72. package/cjs/rules/utility-rules/get-length.js +0 -29
  73. package/cjs/rules/utility-rules/one-of.js +0 -59
  74. package/cjs/rules/utility-rules/optional.js +0 -15
  75. package/cjs/rules/utility-rules/pipe.js +0 -28
  76. package/cjs/rules/utility-rules/required.js +0 -19
  77. package/cjs/tsconfig-build-cjs.tsbuildinfo +0 -1
  78. package/esm/package.json +0 -3
  79. package/esm/tsconfig-build-esm.tsbuildinfo +0 -1
  80. package/types/index.d.cts +0 -65
  81. /package/{types/core → core}/constants.d.ts +0 -0
  82. /package/{esm/core → core}/constants.js +0 -0
  83. /package/{types/core → core}/context.d.ts +0 -0
  84. /package/{types/core → core}/index.d.ts +0 -0
  85. /package/{esm/core → core}/index.js +0 -0
  86. /package/{types/core → core}/types.d.ts +0 -0
  87. /package/{esm/core → core}/types.js +0 -0
  88. /package/{types/core → core}/utilities.d.ts +0 -0
  89. /package/{esm/core → core}/utilities.js +0 -0
  90. /package/{types/core → core}/validation-error.d.ts +0 -0
  91. /package/{types/core → core}/validator.d.ts +0 -0
  92. /package/{esm/core → core}/validator.js +0 -0
  93. /package/{types/factories.d.ts → factories.d.ts} +0 -0
  94. /package/{esm/factories.js → factories.js} +0 -0
  95. /package/{types/helpers → helpers}/object.utils.d.ts +0 -0
  96. /package/{esm/helpers → helpers}/object.utils.js +0 -0
  97. /package/{types/helpers → helpers}/omit-undefined.d.ts +0 -0
  98. /package/{esm/helpers → helpers}/omit-undefined.js +0 -0
  99. /package/{types/helpers → helpers}/string.utils.d.ts +0 -0
  100. /package/{esm/helpers → helpers}/string.utils.js +0 -0
  101. /package/{types/index.d.ts → index.d.ts} +0 -0
  102. /package/{esm/index.js → index.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
@@ -1,30 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.forwardRef = forwardRef;
4
- exports.iif = iif;
5
- const validator_js_1 = require("./validator.js");
6
- /**
7
- * Forwards codec process to a sub codec. Useful for circular checks
8
- * @validator forwardRef
9
- */
10
- function forwardRef(fn) {
11
- return (0, validator_js_1.validator)('forwardRef', (input, context) => {
12
- const nested = fn(context);
13
- return nested(input, context);
14
- });
15
- }
16
- function iif(check, _then, _else) {
17
- return (0, validator_js_1.validator)('iif', (input, context) => {
18
- let c = _else;
19
- try {
20
- if (check(input) !== undefined)
21
- c = _then;
22
- }
23
- catch {
24
- // ignored
25
- }
26
- if ((0, validator_js_1.isValidator)(c))
27
- return c(input, context);
28
- return c;
29
- });
30
- }
@@ -1,12 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.ValidationError = void 0;
4
- class ValidationError extends Error {
5
- constructor(issues) {
6
- super(issues[0].message +
7
- (issues[0].location ? `\n at ${issues[0].location}` : ''));
8
- this.issues = [];
9
- this.issues = issues;
10
- }
11
- }
12
- exports.ValidationError = ValidationError;
@@ -1,71 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.validator = validator;
4
- exports.isValidator = isValidator;
5
- const string_utils_js_1 = require("../helpers/string.utils.js");
6
- const constants_js_1 = require("./constants.js");
7
- const context_js_1 = require("./context.js");
8
- const validation_error_js_1 = require("./validation-error.js");
9
- let unnamedValidatorIndex = 0;
10
- function validator(arg0, arg1, arg2) {
11
- let id = '';
12
- let fn;
13
- let validatorOptions;
14
- if (typeof arg0 === 'string') {
15
- id = arg0;
16
- fn = arg1;
17
- validatorOptions = arg2;
18
- }
19
- else {
20
- fn = arg0;
21
- validatorOptions = arg1;
22
- }
23
- if (typeof fn !== 'function') {
24
- throw new TypeError('You must provide a rule function argument');
25
- }
26
- id = id || fn.name || 'validator' + ++unnamedValidatorIndex;
27
- const name = fn.name || (0, string_utils_js_1.camelCase)(id);
28
- const _rule = {
29
- [name](input, options, context) {
30
- if (context) {
31
- if (options || validatorOptions)
32
- context = context.extend({ ...validatorOptions, ...options });
33
- }
34
- else {
35
- context =
36
- options instanceof context_js_1.Context
37
- ? options.extend({ ...validatorOptions })
38
- : new context_js_1.Context({ ...validatorOptions, ...options });
39
- }
40
- let value;
41
- try {
42
- value = fn(input, context, _rule);
43
- }
44
- catch (e) {
45
- if (e instanceof validation_error_js_1.ValidationError)
46
- throw e;
47
- context.fail(_rule, e, input);
48
- }
49
- if (context.isRoot && context.errors.length) {
50
- throw new validation_error_js_1.ValidationError(context.errors);
51
- }
52
- return value;
53
- },
54
- }[name];
55
- _rule.id = id;
56
- _rule[constants_js_1.kValidatorFn] = fn;
57
- _rule[constants_js_1.kOptions] = validatorOptions || {};
58
- _rule.silent = (input, options, context) => {
59
- try {
60
- const value = _rule(input, options, context);
61
- return { value };
62
- }
63
- catch (e) {
64
- return { errors: e.issues };
65
- }
66
- };
67
- return _rule;
68
- }
69
- function isValidator(x) {
70
- return !!(typeof x === 'function' && x.id && x[constants_js_1.kValidatorFn]);
71
- }
package/cjs/factories.js DELETED
@@ -1,4 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- const tslib_1 = require("tslib");
4
- tslib_1.__exportStar(require("./rules/index.js"), exports);
@@ -1,18 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.omitKeys = omitKeys;
4
- exports.pickKeys = pickKeys;
5
- function omitKeys(o, keys) {
6
- return Object.keys(o).reduce((a, k) => {
7
- if (!keys.includes(k))
8
- a[k] = o[k];
9
- return a;
10
- }, {});
11
- }
12
- function pickKeys(o, keys) {
13
- return Object.keys(o).reduce((a, k) => {
14
- if (keys.includes(k))
15
- a[k] = o[k];
16
- return a;
17
- }, {});
18
- }
@@ -1,14 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.omitUndefined = omitUndefined;
4
- function omitUndefined(obj, recursive) {
5
- if (!(obj && typeof obj === 'object'))
6
- return obj;
7
- for (const k of Object.keys(obj)) {
8
- if (obj[k] === undefined)
9
- delete obj[k];
10
- else if (recursive && typeof obj[k] === 'object')
11
- omitUndefined(obj[k]);
12
- }
13
- return obj;
14
- }
@@ -1,6 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.camelCase = camelCase;
4
- function camelCase(v) {
5
- return v.replace(/[\W_\s]+([^\W_\s])/g, (arg$, c) => c[0].toUpperCase());
6
- }
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
- }