valgen 5.7.0 → 5.8.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 (70) hide show
  1. package/CHANGELOG.md +14 -0
  2. package/cjs/package.json +3 -0
  3. package/esm/constants.js +2 -5
  4. package/esm/core/constants.js +2 -5
  5. package/esm/core/context.js +5 -9
  6. package/esm/core/index.js +6 -9
  7. package/esm/core/types.js +1 -2
  8. package/esm/core/utilities.js +6 -10
  9. package/esm/core/validation-error.js +1 -5
  10. package/esm/core/validator.js +14 -18
  11. package/esm/factories.js +1 -4
  12. package/esm/helpers/object.utils.js +2 -6
  13. package/esm/helpers/omit-undefined.js +1 -4
  14. package/esm/helpers/string.utils.js +1 -4
  15. package/esm/index.js +4 -67
  16. package/esm/package.json +3 -0
  17. package/esm/rules/format-rules/is-alpha.js +6 -11
  18. package/esm/rules/format-rules/is-ascii.js +4 -8
  19. package/esm/rules/format-rules/is-base64.js +4 -8
  20. package/esm/rules/format-rules/is-btc-address.js +4 -8
  21. package/esm/rules/format-rules/is-credit-card.js +4 -8
  22. package/esm/rules/format-rules/is-decimal.js +4 -8
  23. package/esm/rules/format-rules/is-ean.js +4 -8
  24. package/esm/rules/format-rules/is-email.js +4 -8
  25. package/esm/rules/format-rules/is-eth-address.js +4 -8
  26. package/esm/rules/format-rules/is-fqdn.js +4 -8
  27. package/esm/rules/format-rules/is-hash.js +4 -8
  28. package/esm/rules/format-rules/is-hex-color.js +4 -8
  29. package/esm/rules/format-rules/is-hex.js +4 -8
  30. package/esm/rules/format-rules/is-iban.js +6 -11
  31. package/esm/rules/format-rules/is-ip.js +6 -11
  32. package/esm/rules/format-rules/is-issn.js +4 -8
  33. package/esm/rules/format-rules/is-jwt.js +4 -8
  34. package/esm/rules/format-rules/is-lowercase.js +6 -11
  35. package/esm/rules/format-rules/is-mac-address.js +4 -8
  36. package/esm/rules/format-rules/is-mobile-phone.js +4 -8
  37. package/esm/rules/format-rules/is-object-id.js +5 -9
  38. package/esm/rules/format-rules/is-passport-number.js +4 -8
  39. package/esm/rules/format-rules/is-port.js +4 -8
  40. package/esm/rules/format-rules/is-url.js +4 -8
  41. package/esm/rules/format-rules/is-uuid.js +4 -8
  42. package/esm/rules/format-rules/is-vat-number.js +4 -8
  43. package/esm/rules/format-rules/matches.js +3 -6
  44. package/esm/rules/index.js +50 -53
  45. package/esm/rules/logical-rules/is-defined.js +3 -6
  46. package/esm/rules/logical-rules/is-empty.js +5 -9
  47. package/esm/rules/logical-rules/range.js +19 -29
  48. package/esm/rules/type-rules/is-any.js +2 -6
  49. package/esm/rules/type-rules/is-array.js +3 -6
  50. package/esm/rules/type-rules/is-bigint.js +3 -6
  51. package/esm/rules/type-rules/is-boolean.js +3 -6
  52. package/esm/rules/type-rules/is-date.js +10 -14
  53. package/esm/rules/type-rules/is-enum.js +3 -6
  54. package/esm/rules/type-rules/is-integer.js +3 -6
  55. package/esm/rules/type-rules/is-null.js +9 -15
  56. package/esm/rules/type-rules/is-number.js +3 -6
  57. package/esm/rules/type-rules/is-object.js +11 -14
  58. package/esm/rules/type-rules/is-record.js +3 -6
  59. package/esm/rules/type-rules/is-string.js +13 -22
  60. package/esm/rules/type-rules/is-tuple.js +3 -6
  61. package/esm/rules/type-rules/is-undefined.js +3 -6
  62. package/esm/rules/utility-rules/exists.js +3 -6
  63. package/esm/rules/utility-rules/get-length.js +3 -6
  64. package/esm/rules/utility-rules/optional.js +3 -6
  65. package/esm/rules/utility-rules/pipe.js +5 -9
  66. package/esm/rules/utility-rules/required.js +3 -6
  67. package/esm/rules/utility-rules/union.js +3 -6
  68. package/package.json +13 -9
  69. package/types/core/context.d.ts +1 -1
  70. package/types/core/types.d.ts +1 -1
package/CHANGELOG.md CHANGED
@@ -1,3 +1,17 @@
1
+ # v5.8.1
2
+ [2024-08-12]
3
+
4
+ ### Changes
5
+
6
+ * Applied publint to check package.json ([`cf051f4`](https://github.com/panates/valgen/commit/cf051f4fe5944698fda111fdf6efa059eba11309))
7
+
8
+ # v5.8.0
9
+ [2024-08-12]
10
+
11
+ ### Changes
12
+
13
+ * Rollback to ES2020 ([`bb198c6`](https://github.com/panates/valgen/commit/bb198c61aa1b30d83e561d24ebfa4fdb2be1559e))
14
+
1
15
  # v5.7.0
2
16
  [2024-08-09]
3
17
 
@@ -0,0 +1,3 @@
1
+ {
2
+ "type": "commonjs"
3
+ }
package/esm/constants.js CHANGED
@@ -1,5 +1,2 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.preValidation = exports.postValidation = void 0;
4
- exports.postValidation = Symbol('postValidation');
5
- exports.preValidation = Symbol('preValidation');
1
+ export const postValidation = Symbol('postValidation');
2
+ export const preValidation = Symbol('preValidation');
@@ -1,5 +1,2 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.kOptions = exports.kValidatorFn = void 0;
4
- exports.kValidatorFn = Symbol.for('kValidatorFn');
5
- exports.kOptions = Symbol.for('kOptions');
1
+ export const kValidatorFn = Symbol.for('kValidatorFn');
2
+ export const kOptions = Symbol.for('kOptions');
@@ -1,17 +1,14 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.Context = void 0;
4
- const omit_undefined_js_1 = require("../helpers/omit-undefined.js");
5
- const validation_error_js_1 = require("./validation-error.js");
1
+ import { omitUndefined } from '../helpers/omit-undefined.js';
2
+ import { ValidationError } from './validation-error.js';
6
3
  const VARIABLE_REPLACE_PATTERN = /{{([^}]*)}}/g;
7
4
  const OPTIONAL_VAR_PATTERN = /^([^?]+)(?:\||(.*))?$/;
8
- class Context {
5
+ export class Context {
9
6
  constructor(options) {
10
7
  this.errors = [];
11
8
  Object.assign(this, options);
12
9
  }
13
10
  fail(rule, message, value, details) {
14
- const issue = (0, omit_undefined_js_1.omitUndefined)({
11
+ const issue = omitUndefined({
15
12
  message: message instanceof Error ? message.message : String(message),
16
13
  rule: rule.id,
17
14
  root: this.root,
@@ -54,7 +51,7 @@ class Context {
54
51
  });
55
52
  this.errors.push(issue);
56
53
  if (this.errors.length >= (this.maxErrors ?? Infinity)) {
57
- throw new validation_error_js_1.ValidationError(this.errors);
54
+ throw new ValidationError(this.errors);
58
55
  }
59
56
  }
60
57
  extend(options) {
@@ -69,4 +66,3 @@ class Context {
69
66
  return extended;
70
67
  }
71
68
  }
72
- exports.Context = Context;
package/esm/core/index.js CHANGED
@@ -1,9 +1,6 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- const tslib_1 = require("tslib");
4
- tslib_1.__exportStar(require("./constants.js"), exports);
5
- tslib_1.__exportStar(require("./context.js"), exports);
6
- tslib_1.__exportStar(require("./types.js"), exports);
7
- tslib_1.__exportStar(require("./utilities.js"), exports);
8
- tslib_1.__exportStar(require("./validation-error.js"), exports);
9
- tslib_1.__exportStar(require("./validator.js"), exports);
1
+ export * from './constants.js';
2
+ export * from './context.js';
3
+ export * from './types.js';
4
+ export * from './utilities.js';
5
+ export * from './validation-error.js';
6
+ export * from './validator.js';
package/esm/core/types.js CHANGED
@@ -1,2 +1 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
1
+ export {};
@@ -1,20 +1,16 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.forwardRef = forwardRef;
4
- exports.iif = iif;
5
- const index_js_1 = require("./index.js");
1
+ import { isValidator, validator, } from './index.js';
6
2
  /**
7
3
  * Forwards codec process to a sub codec. Useful for circular checks
8
4
  * @validator forwardRef
9
5
  */
10
- function forwardRef(fn) {
11
- return (0, index_js_1.validator)('forwardRef', (input, context) => {
6
+ export function forwardRef(fn) {
7
+ return validator('forwardRef', (input, context) => {
12
8
  const nested = fn(context);
13
9
  return nested(input, context);
14
10
  });
15
11
  }
16
- function iif(check, _then, _else) {
17
- return (0, index_js_1.validator)('iif', (input, context) => {
12
+ export function iif(check, _then, _else) {
13
+ return validator('iif', (input, context) => {
18
14
  let c = _else;
19
15
  try {
20
16
  if (check(input) !== undefined)
@@ -23,7 +19,7 @@ function iif(check, _then, _else) {
23
19
  catch {
24
20
  // ignored
25
21
  }
26
- if ((0, index_js_1.isValidator)(c))
22
+ if (isValidator(c))
27
23
  return c(input, context);
28
24
  return c;
29
25
  });
@@ -1,11 +1,7 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.ValidationError = void 0;
4
- class ValidationError extends Error {
1
+ export class ValidationError extends Error {
5
2
  constructor(issues) {
6
3
  super(issues[0].message);
7
4
  this.issues = [];
8
5
  this.issues = issues;
9
6
  }
10
7
  }
11
- exports.ValidationError = ValidationError;
@@ -1,13 +1,9 @@
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");
1
+ import { camelCase } from '../helpers/string.utils.js';
2
+ import { kOptions, kValidatorFn } from './constants.js';
3
+ import { Context } from './context.js';
4
+ import { ValidationError } from './validation-error.js';
9
5
  let unnamedValidatorIndex = 0;
10
- function validator(arg0, arg1, arg2) {
6
+ export function validator(arg0, arg1, arg2) {
11
7
  let id = '';
12
8
  let fn;
13
9
  let validatorOptions;
@@ -24,31 +20,31 @@ function validator(arg0, arg1, arg2) {
24
20
  throw new TypeError('You must provide a rule function argument');
25
21
  }
26
22
  id = id || fn.name || 'validator' + ++unnamedValidatorIndex;
27
- const name = fn.name || (0, string_utils_js_1.camelCase)(id);
23
+ const name = fn.name || camelCase(id);
28
24
  const _rule = {
29
25
  [name](input, options) {
30
- const ctx = options instanceof context_js_1.Context ? options : undefined;
26
+ const ctx = options instanceof Context ? options : undefined;
31
27
  const opts = ctx ? undefined : options;
32
28
  const context = ctx?.extend({ ...validatorOptions, ...opts }) ||
33
- new context_js_1.Context({ ...validatorOptions, ...opts });
29
+ new Context({ ...validatorOptions, ...opts });
34
30
  let value;
35
31
  try {
36
32
  value = fn(input, context, _rule);
37
33
  }
38
34
  catch (e) {
39
- if (e instanceof validation_error_js_1.ValidationError)
35
+ if (e instanceof ValidationError)
40
36
  throw e;
41
37
  context.fail(_rule, e, input);
42
38
  }
43
39
  if (!ctx && context.errors.length) {
44
- throw new validation_error_js_1.ValidationError(context.errors);
40
+ throw new ValidationError(context.errors);
45
41
  }
46
42
  return value;
47
43
  },
48
44
  }[name];
49
45
  _rule.id = id;
50
- _rule[constants_js_1.kValidatorFn] = fn;
51
- _rule[constants_js_1.kOptions] = validatorOptions || {};
46
+ _rule[kValidatorFn] = fn;
47
+ _rule[kOptions] = validatorOptions || {};
52
48
  _rule.silent = (input, options, context) => {
53
49
  try {
54
50
  const value = _rule(input, options, context);
@@ -60,6 +56,6 @@ function validator(arg0, arg1, arg2) {
60
56
  };
61
57
  return _rule;
62
58
  }
63
- function isValidator(x) {
64
- return !!(typeof x === 'function' && x.id && x[constants_js_1.kValidatorFn]);
59
+ export function isValidator(x) {
60
+ return !!(typeof x === 'function' && x.id && x[kValidatorFn]);
65
61
  }
package/esm/factories.js CHANGED
@@ -1,4 +1 @@
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
+ export * from './rules/index.js';
@@ -1,15 +1,11 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.omitKeys = omitKeys;
4
- exports.pickKeys = pickKeys;
5
- function omitKeys(o, keys) {
1
+ export function omitKeys(o, keys) {
6
2
  return Object.keys(o).reduce((a, k) => {
7
3
  if (!keys.includes(k))
8
4
  a[k] = o[k];
9
5
  return a;
10
6
  }, {});
11
7
  }
12
- function pickKeys(o, keys) {
8
+ export function pickKeys(o, keys) {
13
9
  return Object.keys(o).reduce((a, k) => {
14
10
  if (keys.includes(k))
15
11
  a[k] = o[k];
@@ -1,7 +1,4 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.omitUndefined = omitUndefined;
4
- function omitUndefined(obj, recursive) {
1
+ export function omitUndefined(obj, recursive) {
5
2
  if (!(obj && typeof obj === 'object'))
6
3
  return obj;
7
4
  for (const k of Object.keys(obj)) {
@@ -1,6 +1,3 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.camelCase = camelCase;
4
- function camelCase(v) {
1
+ export function camelCase(v) {
5
2
  return v.replace(/[\W_\s]+([^\W_\s])/g, (arg$, c) => c[0].toUpperCase());
6
3
  }
package/esm/index.js CHANGED
@@ -1,125 +1,62 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.isUUID5 = exports.isUUID4 = exports.isUUID3 = exports.isUUID2 = exports.isUUID1 = exports.isUUID = exports.isURL = exports.isUppercase = exports.isUndefined = 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.toString = exports.toNumber = exports.toInteger = exports.toDateString = exports.toDate = exports.toBoolean = exports.toBigint = exports.toArray = 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);
1
+ import * as vg from './rules/index.js';
2
+ export * from './constants.js';
3
+ export * from './core/index.js';
10
4
  const isAny = vg.isAny();
11
- exports.isAny = isAny;
12
5
  const isArray = vg.isArray();
13
- exports.isArray = isArray;
14
6
  const isBigint = vg.isBigint();
15
- exports.isBigint = isBigint;
16
7
  const isBoolean = vg.isBoolean();
17
- exports.isBoolean = isBoolean;
18
8
  const isDate = vg.isDate();
19
- exports.isDate = isDate;
20
9
  const isDateString = vg.isDateString();
21
- exports.isDateString = isDateString;
22
10
  const isEmpty = vg.isEmpty();
23
- exports.isEmpty = isEmpty;
24
11
  const isNotEmpty = vg.isNotEmpty();
25
- exports.isNotEmpty = isNotEmpty;
26
12
  const isInteger = vg.isInteger();
27
- exports.isInteger = isInteger;
28
13
  const isNull = vg.isNull();
29
- exports.isNull = isNull;
30
14
  const isNotNull = vg.isNotNull();
31
- exports.isNotNull = isNotNull;
32
15
  const isNullish = vg.isNullish();
33
- exports.isNullish = isNullish;
34
16
  const isNotNullish = vg.isNotNullish();
35
- exports.isNotNullish = isNotNullish;
36
17
  const isDefined = vg.isDefined();
37
- exports.isDefined = isDefined;
38
18
  const isUndefined = vg.isUndefined();
39
- exports.isUndefined = isUndefined;
40
19
  const isNumber = vg.isNumber();
41
- exports.isNumber = isNumber;
42
20
  const isObject = vg.isObject();
43
- exports.isObject = isObject;
44
21
  const isObjectId = vg.isObjectId();
45
- exports.isObjectId = isObjectId;
46
22
  const isString = vg.isString();
47
- exports.isString = isString;
48
23
  const isUUID = vg.isUUID();
49
- exports.isUUID = isUUID;
50
24
  const isUUID1 = vg.isUUID(1);
51
- exports.isUUID1 = isUUID1;
52
25
  const isUUID2 = vg.isUUID(2);
53
- exports.isUUID2 = isUUID2;
54
26
  const isUUID3 = vg.isUUID(3);
55
- exports.isUUID3 = isUUID3;
56
27
  const isUUID4 = vg.isUUID(4);
57
- exports.isUUID4 = isUUID4;
58
28
  const isUUID5 = vg.isUUID(5);
59
- exports.isUUID5 = isUUID5;
60
29
  const isEmail = vg.isEmail();
61
- exports.isEmail = isEmail;
62
30
  const isMobilePhone = vg.isMobilePhone();
63
- exports.isMobilePhone = isMobilePhone;
64
31
  const isIP = vg.isIP();
65
- exports.isIP = isIP;
66
32
  const isIPRange = vg.isIPRange();
67
- exports.isIPRange = isIPRange;
68
33
  const isMACAddress = vg.isMACAddress();
69
- exports.isMACAddress = isMACAddress;
70
34
  const isPort = vg.isPort();
71
- exports.isPort = isPort;
72
35
  const isURL = vg.isURL();
73
- exports.isURL = isURL;
74
36
  const isBase64 = vg.isBase64();
75
- exports.isBase64 = isBase64;
76
37
  const isSWIFT = vg.isSWIFT();
77
- exports.isSWIFT = isSWIFT;
78
38
  const isCreditCard = vg.isCreditCard();
79
- exports.isCreditCard = isCreditCard;
80
39
  const isIBAN = vg.isIBAN();
81
- exports.isIBAN = isIBAN;
82
40
  const isEAN = vg.isEAN();
83
- exports.isEAN = isEAN;
84
41
  const isFQDN = vg.isFQDN();
85
- exports.isFQDN = isFQDN;
86
42
  const isISSN = vg.isISSN();
87
- exports.isISSN = isISSN;
88
43
  const isBtcAddress = vg.isBtcAddress();
89
- exports.isBtcAddress = isBtcAddress;
90
44
  const isETHAddress = vg.isETHAddress();
91
- exports.isETHAddress = isETHAddress;
92
45
  const isHexColor = vg.isHexColor();
93
- exports.isHexColor = isHexColor;
94
46
  const isJWT = vg.isJWT();
95
- exports.isJWT = isJWT;
96
47
  const isLowercase = vg.isLowercase();
97
- exports.isLowercase = isLowercase;
98
48
  const isUppercase = vg.isUppercase();
99
- exports.isUppercase = isUppercase;
100
49
  const isAlpha = vg.isAlpha();
101
- exports.isAlpha = isAlpha;
102
50
  const isAlphanumeric = vg.isAlphanumeric();
103
- exports.isAlphanumeric = isAlphanumeric;
104
51
  const isAscii = vg.isAscii();
105
- exports.isAscii = isAscii;
106
52
  const isDecimal = vg.isDecimal();
107
- exports.isDecimal = isDecimal;
108
53
  const isHex = vg.isHex();
109
- exports.isHex = isHex;
110
54
  const toArray = vg.isArray(isAny, { coerce: true });
111
- exports.toArray = toArray;
112
55
  const toBoolean = vg.isBoolean({ coerce: true });
113
- exports.toBoolean = toBoolean;
114
56
  const toDate = vg.isDate({ coerce: true });
115
- exports.toDate = toDate;
116
57
  const toBigint = vg.isBigint({ coerce: true });
117
- exports.toBigint = toBigint;
118
58
  const toDateString = vg.isDateString({ coerce: true });
119
- exports.toDateString = toDateString;
120
59
  const toInteger = vg.isInteger({ coerce: true });
121
- exports.toInteger = toInteger;
122
60
  const toNumber = vg.isNumber({ coerce: true });
123
- exports.toNumber = toNumber;
124
61
  const toString = vg.isString({ coerce: true });
125
- exports.toString = toString;
62
+ export { isAlpha, isAlphanumeric, isAny, isArray, isAscii, isBase64, isBigint, isBoolean, isBtcAddress, isCreditCard, isDate, isDateString, isDecimal, isDefined, isEAN, isEmail, isEmpty, isETHAddress, isFQDN, isHex, isHexColor, isIBAN, isInteger, isIP, isIPRange, isISSN, isJWT, isLowercase, isMACAddress, isMobilePhone, isNotEmpty, isNotNull, isNotNullish, isNull, isNullish, isNumber, isObject, isObjectId, isPort, isString, isSWIFT, isUndefined, isUppercase, isURL, isUUID, isUUID1, isUUID2, isUUID3, isUUID4, isUUID5, toArray, toBigint, toBoolean, toDate, toDateString, toInteger, toNumber, toString, vg, };
@@ -0,0 +1,3 @@
1
+ {
2
+ "type": "module"
3
+ }
@@ -1,16 +1,11 @@
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 validatorJS = tslib_1.__importStar(require("validator"));
7
- const index_js_1 = require("../../core/index.js");
1
+ import * as validatorJS from 'validator';
2
+ import { validator } from '../../core/index.js';
8
3
  /**
9
4
  * Check if the string contains only letters (a-zA-Z).
10
5
  * @validator isAlpha
11
6
  */
12
- function isAlpha(options) {
13
- return (0, index_js_1.validator)('isLowercase', (input, context, _this) => {
7
+ export function isAlpha(options) {
8
+ return validator('isLowercase', (input, context, _this) => {
14
9
  if (typeof input === 'string' && validatorJS.isAlpha(input))
15
10
  return input;
16
11
  context.fail(_this, `"{{value}}" is not an alpha string`, input);
@@ -20,8 +15,8 @@ function isAlpha(options) {
20
15
  * Check if the string contains only letters and numbers.
21
16
  * @validator isAlphanumeric
22
17
  */
23
- function isAlphanumeric(options) {
24
- return (0, index_js_1.validator)('isAlphanumeric', (input, context, _this) => {
18
+ export function isAlphanumeric(options) {
19
+ return validator('isAlphanumeric', (input, context, _this) => {
25
20
  if (typeof input === 'string' && validatorJS.isAlphanumeric(input)) {
26
21
  return input;
27
22
  }
@@ -1,15 +1,11 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.isAscii = isAscii;
4
- const tslib_1 = require("tslib");
5
- const validatorJS = tslib_1.__importStar(require("validator"));
6
- const index_js_1 = require("../../core/index.js");
1
+ import * as validatorJS from 'validator';
2
+ import { validator } from '../../core/index.js';
7
3
  /**
8
4
  * Check if the string contains ASCII chars only.
9
5
  * @validator isAscii
10
6
  */
11
- function isAscii(options) {
12
- return (0, index_js_1.validator)('isAscii', (input, context, _this) => {
7
+ export function isAscii(options) {
8
+ return validator('isAscii', (input, context, _this) => {
13
9
  if (typeof input === 'string' && validatorJS.isAscii(input))
14
10
  return input;
15
11
  context.fail(_this, `Value is not an ascii string`, input);
@@ -1,15 +1,11 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.isBase64 = isBase64;
4
- const tslib_1 = require("tslib");
5
- const validatorJS = tslib_1.__importStar(require("validator"));
6
- const index_js_1 = require("../../core/index.js");
1
+ import * as validatorJS from 'validator';
2
+ import { validator } from '../../core/index.js';
7
3
  /**
8
4
  * Validates if value is a "Base64" string.
9
5
  * @validator isBase64
10
6
  */
11
- function isBase64(options) {
12
- return (0, index_js_1.validator)('isBase64', (input, context, _this) => {
7
+ export function isBase64(options) {
8
+ return validator('isBase64', (input, context, _this) => {
13
9
  if (typeof input === 'string' && validatorJS.isBase64(input, options)) {
14
10
  return input;
15
11
  }
@@ -1,15 +1,11 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.isBtcAddress = isBtcAddress;
4
- const tslib_1 = require("tslib");
5
- const validatorJS = tslib_1.__importStar(require("validator"));
6
- const index_js_1 = require("../../core/index.js");
1
+ import * as validatorJS from 'validator';
2
+ import { validator } from '../../core/index.js';
7
3
  /**
8
4
  * Validates if value is a BTC address.
9
5
  * @validator isBtcAddress
10
6
  */
11
- function isBtcAddress(options) {
12
- return (0, index_js_1.validator)('isBtcAddress', (input, context, _this) => {
7
+ export function isBtcAddress(options) {
8
+ return validator('isBtcAddress', (input, context, _this) => {
13
9
  if (typeof input === 'string' && validatorJS.isBtcAddress(input)) {
14
10
  return input;
15
11
  }
@@ -1,15 +1,11 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.isCreditCard = isCreditCard;
4
- const tslib_1 = require("tslib");
5
- const validatorJS = tslib_1.__importStar(require("validator"));
6
- const index_js_1 = require("../../core/index.js");
1
+ import * as validatorJS from 'validator';
2
+ import { validator } from '../../core/index.js';
7
3
  /**
8
4
  * Validates if value is a credit card number
9
5
  * @validator isCreditCard
10
6
  */
11
- function isCreditCard(options) {
12
- return (0, index_js_1.validator)('isCreditCard', (input, context, _this) => {
7
+ export function isCreditCard(options) {
8
+ return validator('isCreditCard', (input, context, _this) => {
13
9
  if (typeof input === 'string' &&
14
10
  validatorJS.isCreditCard(input, options)) {
15
11
  return input;
@@ -1,16 +1,12 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.isDecimal = isDecimal;
4
- const tslib_1 = require("tslib");
5
- const validatorJS = tslib_1.__importStar(require("validator"));
6
- const index_js_1 = require("../../core/index.js");
1
+ import * as validatorJS from 'validator';
2
+ import { validator } from '../../core/index.js';
7
3
  /**
8
4
  * Check if the string represents a decimal number,
9
5
  * such as `0.1`, `.3`, `1.1`, `1.00003`, `4.0` etc.
10
6
  * @validator isDecimal
11
7
  */
12
- function isDecimal(options) {
13
- return (0, index_js_1.validator)('isDecimal', (input, context, _this) => {
8
+ export function isDecimal(options) {
9
+ return validator('isDecimal', (input, context, _this) => {
14
10
  if (typeof input === 'string' && validatorJS.isDecimal(input)) {
15
11
  return input;
16
12
  }
@@ -1,15 +1,11 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.isEAN = isEAN;
4
- const tslib_1 = require("tslib");
5
- const validatorJS = tslib_1.__importStar(require("validator"));
6
- const index_js_1 = require("../../core/index.js");
1
+ import * as validatorJS from 'validator';
2
+ import { validator } from '../../core/index.js';
7
3
  /**
8
4
  * Validates if value is an EAN (European Article Number)
9
5
  * @validator isEAN
10
6
  */
11
- function isEAN(options) {
12
- return (0, index_js_1.validator)('isEAN', (input, context, _this) => {
7
+ export function isEAN(options) {
8
+ return validator('isEAN', (input, context, _this) => {
13
9
  if (typeof input === 'string' && validatorJS.isEAN(input))
14
10
  return input;
15
11
  context.fail(_this, `"{{value}}" is not a valid EAN (European Article Number)`, input);
@@ -1,14 +1,10 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.isEmail = isEmail;
4
- const tslib_1 = require("tslib");
5
- const validatorJS = tslib_1.__importStar(require("validator"));
6
- const index_js_1 = require("../../core/index.js");
1
+ import * as validatorJS from 'validator';
2
+ import { validator } from '../../core/index.js';
7
3
  /**
8
4
  * Validates if value is a valid Email
9
5
  * @validator isEmail
10
6
  */
11
- function isEmail(options) {
7
+ export function isEmail(options) {
12
8
  const emailOptions = {
13
9
  // eslint-disable-next-line camelcase
14
10
  allow_display_name: true,
@@ -19,7 +15,7 @@ function isEmail(options) {
19
15
  // eslint-disable-next-line camelcase
20
16
  allow_ip_domain: options?.allowIpDomain,
21
17
  };
22
- return (0, index_js_1.validator)('isEmail', (input, context, _this) => {
18
+ return validator('isEmail', (input, context, _this) => {
23
19
  if (typeof input === 'string' &&
24
20
  validatorJS.isEmail(input, emailOptions)) {
25
21
  if (options?.requireDisplayName) {
@@ -1,15 +1,11 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.isETHAddress = isETHAddress;
4
- const tslib_1 = require("tslib");
5
- const validatorJS = tslib_1.__importStar(require("validator"));
6
- const index_js_1 = require("../../core/index.js");
1
+ import * as validatorJS from 'validator';
2
+ import { validator } from '../../core/index.js';
7
3
  /**
8
4
  * Validates if value is a ETH (Ethereum) address.
9
5
  * @validator isETHAddress
10
6
  */
11
- function isETHAddress(options) {
12
- return (0, index_js_1.validator)('isETHAddress', (input, context, _this) => {
7
+ export function isETHAddress(options) {
8
+ return validator('isETHAddress', (input, context, _this) => {
13
9
  if (typeof input === 'string' && validatorJS.isEthereumAddress(input)) {
14
10
  return input;
15
11
  }
@@ -1,19 +1,15 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.isFQDN = isFQDN;
4
- const tslib_1 = require("tslib");
5
- const validatorJS = tslib_1.__importStar(require("validator"));
6
- const index_js_1 = require("../../core/index.js");
1
+ import * as validatorJS from 'validator';
2
+ import { validator } from '../../core/index.js';
7
3
  /**
8
4
  * Validates if value is an FQDN
9
5
  * @validator isFQDN
10
6
  */
11
- function isFQDN(options) {
7
+ export function isFQDN(options) {
12
8
  const opts = {
13
9
  // eslint-disable-next-line camelcase
14
10
  allow_wildcard: options?.allowWildcard,
15
11
  };
16
- return (0, index_js_1.validator)('isFQDN', (input, context, _this) => {
12
+ return validator('isFQDN', (input, context, _this) => {
17
13
  if (typeof input === 'string' && validatorJS.isFQDN(input, opts)) {
18
14
  return input;
19
15
  }