n4s 5.0.1 → 5.0.2

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 (80) hide show
  1. package/CHANGELOG.md +0 -4
  2. package/README.md +2 -0
  3. package/compose/package.json +2 -0
  4. package/compounds/package.json +2 -0
  5. package/date/package.json +9 -0
  6. package/dist/cjs/compose.development.js +14 -97
  7. package/dist/cjs/compose.js +0 -1
  8. package/dist/cjs/compose.production.js +1 -1
  9. package/dist/cjs/compounds.development.js +30 -86
  10. package/dist/cjs/compounds.js +0 -1
  11. package/dist/cjs/compounds.production.js +1 -1
  12. package/dist/cjs/date.development.js +186 -0
  13. package/dist/cjs/date.js +6 -0
  14. package/dist/cjs/date.production.js +1 -0
  15. package/dist/cjs/email.development.js +363 -0
  16. package/dist/cjs/email.js +6 -0
  17. package/dist/cjs/email.production.js +1 -0
  18. package/dist/cjs/isURL.development.js +353 -0
  19. package/dist/cjs/isURL.js +6 -0
  20. package/dist/cjs/isURL.production.js +1 -0
  21. package/dist/cjs/n4s.development.js +205 -387
  22. package/dist/cjs/n4s.js +0 -1
  23. package/dist/cjs/n4s.production.js +1 -1
  24. package/dist/cjs/schema.development.js +19 -80
  25. package/dist/cjs/schema.js +0 -1
  26. package/dist/cjs/schema.production.js +1 -1
  27. package/dist/es/compose.development.js +14 -97
  28. package/dist/es/compose.production.js +1 -1
  29. package/dist/es/compounds.development.js +28 -84
  30. package/dist/es/compounds.production.js +1 -1
  31. package/dist/es/date.development.js +184 -0
  32. package/dist/es/date.production.js +1 -0
  33. package/dist/es/email.development.js +361 -0
  34. package/dist/es/email.production.js +1 -0
  35. package/dist/es/isURL.development.js +351 -0
  36. package/dist/es/isURL.production.js +1 -0
  37. package/dist/es/n4s.development.js +192 -372
  38. package/dist/es/n4s.production.js +1 -1
  39. package/dist/es/schema.development.js +16 -75
  40. package/dist/es/schema.production.js +1 -1
  41. package/dist/umd/compose.development.js +18 -102
  42. package/dist/umd/compose.production.js +1 -1
  43. package/dist/umd/compounds.development.js +34 -91
  44. package/dist/umd/compounds.production.js +1 -1
  45. package/dist/umd/date.development.js +190 -0
  46. package/dist/umd/date.production.js +1 -0
  47. package/dist/umd/email.development.js +367 -0
  48. package/dist/umd/email.production.js +1 -0
  49. package/dist/umd/isURL.development.js +357 -0
  50. package/dist/umd/isURL.production.js +1 -0
  51. package/dist/umd/n4s.development.js +209 -392
  52. package/dist/umd/n4s.production.js +1 -1
  53. package/dist/umd/schema.development.js +23 -85
  54. package/dist/umd/schema.production.js +1 -1
  55. package/email/package.json +9 -0
  56. package/isURL/package.json +9 -0
  57. package/package.json +162 -55
  58. package/schema/package.json +2 -0
  59. package/testUtils/TEnforceMock.ts +3 -0
  60. package/types/compose.d.ts +46 -55
  61. package/types/compose.d.ts.map +1 -0
  62. package/types/compounds.d.ts +50 -62
  63. package/types/compounds.d.ts.map +1 -0
  64. package/types/date.d.ts +18 -0
  65. package/types/date.d.ts.map +1 -0
  66. package/types/email.d.ts +12 -0
  67. package/types/email.d.ts.map +1 -0
  68. package/types/isURL.d.ts +12 -0
  69. package/types/isURL.d.ts.map +1 -0
  70. package/types/n4s.d.ts +62 -73
  71. package/types/n4s.d.ts.map +1 -0
  72. package/types/schema.d.ts +55 -63
  73. package/types/schema.d.ts.map +1 -0
  74. package/docs/.nojekyll +0 -0
  75. package/docs/README.md +0 -44
  76. package/docs/_sidebar.md +0 -5
  77. package/docs/external.md +0 -27
  78. package/docs/index.html +0 -32
  79. package/docs/rules.md +0 -1282
  80. package/tsconfig.json +0 -8
@@ -1,49 +1,32 @@
1
- type DropFirst<T extends unknown[]> = T extends [
2
- unknown,
3
- ...infer U
4
- ] ? U : never;
5
- type TStringable = string | ((...args: any[]) => string);
6
- type TRuleReturn = boolean | {
1
+ import { CB, Stringable, DynamicValue, DropFirst, BlankValue } from "vest-utils";
2
+ type RuleReturn = boolean | {
7
3
  pass: boolean;
8
- message?: TStringable;
4
+ message?: Stringable;
9
5
  };
10
- type TRuleDetailedResult = {
6
+ type RuleDetailedResult = {
11
7
  pass: boolean;
12
8
  message?: string;
13
9
  };
14
- type TArgs = any[];
15
- type TBaseRules = typeof baseRules;
16
- type KBaseRules = keyof TBaseRules;
17
- declare function condition(value: any, callback: (value: any) => TRuleReturn): TRuleReturn;
10
+ type Args = any[];
11
+ type BaseRules = typeof baseRules;
12
+ type KBaseRules = keyof BaseRules;
13
+ declare function condition(value: any, callback: (value: any) => RuleReturn): RuleReturn;
18
14
  declare function endsWith(value: string, arg1: string): boolean;
19
15
  declare function equals(value: unknown, arg1: unknown): boolean;
20
- declare function greaterThan(value: number | string, gt: number | string): boolean;
21
16
  declare function greaterThanOrEquals(value: string | number, gte: string | number): boolean;
22
17
  declare function inside(value: unknown, arg1: string | unknown[]): boolean;
23
- // The module is named "isArrayValue" since it
24
- // is conflicting with a nested npm dependency.
25
- // We may need to revisit this in the future.
26
- declare function isArray(value: unknown): value is Array<unknown>;
27
18
  declare function isBetween(value: number | string, min: number | string, max: number | string): boolean;
28
- declare function isBlank(value: unknown): boolean;
29
- declare function isBoolean(value: unknown): value is boolean;
30
- declare function isEmpty(value: unknown): boolean;
19
+ declare function isBlank(value: unknown): value is BlankValue;
20
+ declare function isKeyOf(key: string | symbol | number, obj: any): boolean;
31
21
  declare function isNaN(value: unknown): boolean;
32
22
  declare function isNegative(value: number | string): boolean;
33
- declare function isNull(value: unknown): value is null;
34
- declare function isNullish(value: any): value is null | undefined;
35
23
  declare function isNumber(value: unknown): value is number;
36
- declare function isNumeric(value: string | number): boolean;
37
- declare function isStringValue(v: unknown): v is string;
38
24
  declare function isTruthy(value: unknown): boolean;
39
- declare function isUndefined(value?: unknown): boolean;
40
- declare function lengthEquals(value: string | unknown[], arg1: string | number): boolean;
25
+ declare function isValueOf(value: any, objectToCheck: any): boolean;
41
26
  declare function lessThan(value: string | number, lt: string | number): boolean;
42
27
  declare function lessThanOrEquals(value: string | number, lte: string | number): boolean;
43
- declare function longerThan(value: string | unknown[], arg1: string | number): boolean;
44
28
  declare function longerThanOrEquals(value: string | unknown[], arg1: string | number): boolean;
45
29
  declare function matches(value: string, regex: RegExp | string): boolean;
46
- declare function numberEquals(value: string | number, eq: string | number): boolean;
47
30
  declare function shorterThan(value: string | unknown[], arg1: string | number): boolean;
48
31
  declare function shorterThanOrEquals(value: string | unknown[], arg1: string | number): boolean;
49
32
  declare function startsWith(value: string, arg1: string): boolean;
@@ -53,18 +36,19 @@ declare const baseRules: {
53
36
  doesNotStartWith: (value: string, arg1: string) => boolean;
54
37
  endsWith: typeof endsWith;
55
38
  equals: typeof equals;
56
- greaterThan: typeof greaterThan;
39
+ greaterThan: typeof import("vest-utils").greaterThan;
57
40
  greaterThanOrEquals: typeof greaterThanOrEquals;
58
- gt: typeof greaterThan;
41
+ gt: typeof import("vest-utils").greaterThan;
59
42
  gte: typeof greaterThanOrEquals;
60
43
  inside: typeof inside;
61
- isArray: typeof isArray;
44
+ isArray: typeof import("vest-utils").isArray;
62
45
  isBetween: typeof isBetween;
63
46
  isBlank: typeof isBlank;
64
- isBoolean: typeof isBoolean;
65
- isEmpty: typeof isEmpty;
47
+ isBoolean: typeof import("vest-utils").isBoolean;
48
+ isEmpty: typeof import("vest-utils").isEmpty;
66
49
  isEven: (value: any) => boolean;
67
50
  isFalsy: (value: unknown) => boolean;
51
+ isKeyOf: typeof isKeyOf;
68
52
  isNaN: typeof isNaN;
69
53
  isNegative: typeof isNegative;
70
54
  isNotArray: (value: unknown) => boolean;
@@ -72,6 +56,7 @@ declare const baseRules: {
72
56
  isNotBlank: (value: unknown) => boolean;
73
57
  isNotBoolean: (value: unknown) => boolean;
74
58
  isNotEmpty: (value: unknown) => boolean;
59
+ isNotKeyOf: (key: string | number | symbol, obj: any) => boolean;
75
60
  isNotNaN: (value: unknown) => boolean;
76
61
  isNotNull: (value: unknown) => boolean;
77
62
  isNotNullish: (value: any) => boolean;
@@ -79,20 +64,22 @@ declare const baseRules: {
79
64
  isNotNumeric: (value: string | number) => boolean;
80
65
  isNotString: (v: unknown) => boolean;
81
66
  isNotUndefined: (value?: unknown) => boolean;
82
- isNull: typeof isNull;
83
- isNullish: typeof isNullish;
67
+ isNotValueOf: (value: any, objectToCheck: any) => boolean;
68
+ isNull: typeof import("vest-utils").isNull;
69
+ isNullish: typeof import("vest-utils").isNullish;
84
70
  isNumber: typeof isNumber;
85
- isNumeric: typeof isNumeric;
71
+ isNumeric: typeof import("vest-utils").isNumeric;
86
72
  isOdd: (value: any) => boolean;
87
- isPositive: (value: string | number) => boolean;
88
- isString: typeof isStringValue;
73
+ isPositive: typeof import("vest-utils").isPositive;
74
+ isString: typeof import("vest-utils").isStringValue;
89
75
  isTruthy: typeof isTruthy;
90
- isUndefined: typeof isUndefined;
91
- lengthEquals: typeof lengthEquals;
76
+ isUndefined: typeof import("vest-utils").isUndefined;
77
+ isValueOf: typeof isValueOf;
78
+ lengthEquals: typeof import("vest-utils").lengthEquals;
92
79
  lengthNotEquals: (value: string | unknown[], arg1: string | number) => boolean;
93
80
  lessThan: typeof lessThan;
94
81
  lessThanOrEquals: typeof lessThanOrEquals;
95
- longerThan: typeof longerThan;
82
+ longerThan: typeof import("vest-utils").longerThan;
96
83
  longerThanOrEquals: typeof longerThanOrEquals;
97
84
  lt: typeof lessThan;
98
85
  lte: typeof lessThanOrEquals;
@@ -100,35 +87,39 @@ declare const baseRules: {
100
87
  notEquals: (value: unknown, arg1: unknown) => boolean;
101
88
  notInside: (value: unknown, arg1: string | unknown[]) => boolean;
102
89
  notMatches: (value: string, regex: string | RegExp) => boolean;
103
- numberEquals: typeof numberEquals;
90
+ numberEquals: typeof import("vest-utils").numberEquals;
104
91
  numberNotEquals: (value: string | number, eq: string | number) => boolean;
105
92
  shorterThan: typeof shorterThan;
106
93
  shorterThanOrEquals: typeof shorterThanOrEquals;
107
94
  startsWith: typeof startsWith;
108
95
  };
109
- type TRules<E = Record<string, unknown>> = n4s.EnforceCustomMatchers<TRules<E> & E> & Record<string, (...args: TArgs) => TRules<E> & E> & {
110
- [P in KBaseRules]: (...args: DropFirst<Parameters<TBaseRules[P]>> | TArgs) => TRules<E> & E;
96
+ type Rules<E = Record<string, unknown>> = n4s.EnforceCustomMatchers<Rules<E> & E> & Record<string, (...args: Args) => Rules<E> & E> & {
97
+ [P in KBaseRules]: (...args: DropFirst<Parameters<BaseRules[P]>> | Args) => Rules<E> & E;
111
98
  };
112
99
  /* eslint-disable @typescript-eslint/no-namespace, @typescript-eslint/no-empty-interface */
113
100
  declare global {
114
101
  namespace n4s {
115
- interface IRules<E> extends TRules<E> {
102
+ interface IRules<E> extends Rules<E> {
116
103
  }
117
104
  }
118
105
  }
119
- type TLazyRules = n4s.IRules<TLazyRuleMethods>;
120
- type TLazy = TLazyRules & TLazyRuleMethods &
106
+ type LazyRules = n4s.IRules<LazyRuleMethods>;
107
+ type Lazy = LazyRules & LazyRuleMethods &
121
108
  // This is a "catch all" hack to make TS happy while not
122
109
  // losing type hints
123
- Record<string, (...args: any[]) => any>;
124
- type TLazyRuleMethods = TLazyRuleRunners & {
125
- message: (message: TLazyMessage) => TLazy;
110
+ Record<string, CB>;
111
+ type LazyRuleMethods = LazyRuleRunners & {
112
+ message: (message: LazyMessage) => Lazy;
126
113
  };
127
- type TLazyRuleRunners = {
114
+ type LazyRuleRunners = {
128
115
  test: (value: unknown) => boolean;
129
- run: (value: unknown) => TRuleDetailedResult;
116
+ run: (value: unknown) => RuleDetailedResult;
130
117
  };
131
- type TComposeResult = TLazyRuleRunners & ((value: any) => void);
132
- type TLazyMessage = string | ((value: unknown, originalMessage?: TStringable) => string);
133
- declare function compose(...composites: TLazyRuleRunners[]): TComposeResult;
118
+ type ComposeResult = LazyRuleRunners & ((value: any) => void);
119
+ type LazyMessage = DynamicValue<string, [
120
+ value: unknown,
121
+ originalMessage?: Stringable
122
+ ]>;
123
+ declare function compose(...composites: LazyRuleRunners[]): ComposeResult;
134
124
  export { compose as default };
125
+ //# sourceMappingURL=compose.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"compose.d.ts","sourceRoot":"","sources":["../src/exports/compose.ts","../src/runtime/enforceContext.ts","../src/lib/ruleReturn.ts","../src/rules/endsWith.ts","../src/rules/equals.ts","../src/rules/greaterThanOrEquals.ts","../src/rules/inside.ts","../src/rules/lessThan.ts","../src/rules/lessThanOrEquals.ts","../src/rules/isBetween.ts","../src/rules/isBlank.ts","../src/rules/isBoolean.ts","../src/rules/isEven.ts","../src/rules/isKeyOf.ts","../src/rules/isNaN.ts","../src/rules/isNegative.ts","../src/rules/isNumber.ts","../src/rules/isOdd.ts","../src/rules/isString.ts","../src/rules/isTruthy.ts","../src/rules/isValueOf.ts","../src/rules/longerThanOrEquals.ts","../src/rules/matches.ts","../src/rules/ruleCondition.ts","../src/rules/shorterThan.ts","../src/rules/shorterThanOrEquals.ts","../src/rules/startsWith.ts","../src/runtime/rules.ts","../src/runtime/runtimeRules.ts","../src/lib/transformResult.ts","../src/runtime/genEnforceLazy.ts","../src/lib/runLazyRule.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AASA,iBAAwB,OAAO,CAC7B,GAAG,UAAU,EAAE,eAAe,EAAE,GAC/B,aAAa,CAoCf"}
@@ -1,49 +1,33 @@
1
- type DropFirst<T extends unknown[]> = T extends [
2
- unknown,
3
- ...infer U
4
- ] ? U : never;
5
- type TStringable = string | ((...args: any[]) => string);
6
- type TRuleReturn = boolean | {
1
+ import { CB, DropFirst, Stringable, DynamicValue, BlankValue } from "vest-utils";
2
+ type EnforceCustomMatcher<F extends CB, R> = (...args: DropFirst<Parameters<F>>) => R;
3
+ type RuleReturn = boolean | {
7
4
  pass: boolean;
8
- message?: TStringable;
5
+ message?: Stringable;
9
6
  };
10
- type TRuleDetailedResult = {
7
+ type RuleDetailedResult = {
11
8
  pass: boolean;
12
9
  message?: string;
13
10
  };
14
- type TArgs = any[];
15
- type TBaseRules = typeof baseRules;
16
- type KBaseRules = keyof TBaseRules;
17
- declare function condition(value: any, callback: (value: any) => TRuleReturn): TRuleReturn;
11
+ type Args = any[];
12
+ type BaseRules = typeof baseRules;
13
+ type KBaseRules = keyof BaseRules;
14
+ declare function condition(value: any, callback: (value: any) => RuleReturn): RuleReturn;
18
15
  declare function endsWith(value: string, arg1: string): boolean;
19
16
  declare function equals(value: unknown, arg1: unknown): boolean;
20
- declare function greaterThan(value: number | string, gt: number | string): boolean;
21
17
  declare function greaterThanOrEquals(value: string | number, gte: string | number): boolean;
22
18
  declare function inside(value: unknown, arg1: string | unknown[]): boolean;
23
- // The module is named "isArrayValue" since it
24
- // is conflicting with a nested npm dependency.
25
- // We may need to revisit this in the future.
26
- declare function isArray(value: unknown): value is Array<unknown>;
27
19
  declare function isBetween(value: number | string, min: number | string, max: number | string): boolean;
28
- declare function isBlank(value: unknown): boolean;
29
- declare function isBoolean(value: unknown): value is boolean;
30
- declare function isEmpty(value: unknown): boolean;
20
+ declare function isBlank(value: unknown): value is BlankValue;
21
+ declare function isKeyOf(key: string | symbol | number, obj: any): boolean;
31
22
  declare function isNaN(value: unknown): boolean;
32
23
  declare function isNegative(value: number | string): boolean;
33
- declare function isNull(value: unknown): value is null;
34
- declare function isNullish(value: any): value is null | undefined;
35
24
  declare function isNumber(value: unknown): value is number;
36
- declare function isNumeric(value: string | number): boolean;
37
- declare function isStringValue(v: unknown): v is string;
38
25
  declare function isTruthy(value: unknown): boolean;
39
- declare function isUndefined(value?: unknown): boolean;
40
- declare function lengthEquals(value: string | unknown[], arg1: string | number): boolean;
26
+ declare function isValueOf(value: any, objectToCheck: any): boolean;
41
27
  declare function lessThan(value: string | number, lt: string | number): boolean;
42
28
  declare function lessThanOrEquals(value: string | number, lte: string | number): boolean;
43
- declare function longerThan(value: string | unknown[], arg1: string | number): boolean;
44
29
  declare function longerThanOrEquals(value: string | unknown[], arg1: string | number): boolean;
45
30
  declare function matches(value: string, regex: RegExp | string): boolean;
46
- declare function numberEquals(value: string | number, eq: string | number): boolean;
47
31
  declare function shorterThan(value: string | unknown[], arg1: string | number): boolean;
48
32
  declare function shorterThanOrEquals(value: string | unknown[], arg1: string | number): boolean;
49
33
  declare function startsWith(value: string, arg1: string): boolean;
@@ -53,18 +37,19 @@ declare const baseRules: {
53
37
  doesNotStartWith: (value: string, arg1: string) => boolean;
54
38
  endsWith: typeof endsWith;
55
39
  equals: typeof equals;
56
- greaterThan: typeof greaterThan;
40
+ greaterThan: typeof import("vest-utils").greaterThan;
57
41
  greaterThanOrEquals: typeof greaterThanOrEquals;
58
- gt: typeof greaterThan;
42
+ gt: typeof import("vest-utils").greaterThan;
59
43
  gte: typeof greaterThanOrEquals;
60
44
  inside: typeof inside;
61
- isArray: typeof isArray;
45
+ isArray: typeof import("vest-utils").isArray;
62
46
  isBetween: typeof isBetween;
63
47
  isBlank: typeof isBlank;
64
- isBoolean: typeof isBoolean;
65
- isEmpty: typeof isEmpty;
48
+ isBoolean: typeof import("vest-utils").isBoolean;
49
+ isEmpty: typeof import("vest-utils").isEmpty;
66
50
  isEven: (value: any) => boolean;
67
51
  isFalsy: (value: unknown) => boolean;
52
+ isKeyOf: typeof isKeyOf;
68
53
  isNaN: typeof isNaN;
69
54
  isNegative: typeof isNegative;
70
55
  isNotArray: (value: unknown) => boolean;
@@ -72,6 +57,7 @@ declare const baseRules: {
72
57
  isNotBlank: (value: unknown) => boolean;
73
58
  isNotBoolean: (value: unknown) => boolean;
74
59
  isNotEmpty: (value: unknown) => boolean;
60
+ isNotKeyOf: (key: string | number | symbol, obj: any) => boolean;
75
61
  isNotNaN: (value: unknown) => boolean;
76
62
  isNotNull: (value: unknown) => boolean;
77
63
  isNotNullish: (value: any) => boolean;
@@ -79,20 +65,22 @@ declare const baseRules: {
79
65
  isNotNumeric: (value: string | number) => boolean;
80
66
  isNotString: (v: unknown) => boolean;
81
67
  isNotUndefined: (value?: unknown) => boolean;
82
- isNull: typeof isNull;
83
- isNullish: typeof isNullish;
68
+ isNotValueOf: (value: any, objectToCheck: any) => boolean;
69
+ isNull: typeof import("vest-utils").isNull;
70
+ isNullish: typeof import("vest-utils").isNullish;
84
71
  isNumber: typeof isNumber;
85
- isNumeric: typeof isNumeric;
72
+ isNumeric: typeof import("vest-utils").isNumeric;
86
73
  isOdd: (value: any) => boolean;
87
- isPositive: (value: string | number) => boolean;
88
- isString: typeof isStringValue;
74
+ isPositive: typeof import("vest-utils").isPositive;
75
+ isString: typeof import("vest-utils").isStringValue;
89
76
  isTruthy: typeof isTruthy;
90
- isUndefined: typeof isUndefined;
91
- lengthEquals: typeof lengthEquals;
77
+ isUndefined: typeof import("vest-utils").isUndefined;
78
+ isValueOf: typeof isValueOf;
79
+ lengthEquals: typeof import("vest-utils").lengthEquals;
92
80
  lengthNotEquals: (value: string | unknown[], arg1: string | number) => boolean;
93
81
  lessThan: typeof lessThan;
94
82
  lessThanOrEquals: typeof lessThanOrEquals;
95
- longerThan: typeof longerThan;
83
+ longerThan: typeof import("vest-utils").longerThan;
96
84
  longerThanOrEquals: typeof longerThanOrEquals;
97
85
  lt: typeof lessThan;
98
86
  lte: typeof lessThanOrEquals;
@@ -100,47 +88,47 @@ declare const baseRules: {
100
88
  notEquals: (value: unknown, arg1: unknown) => boolean;
101
89
  notInside: (value: unknown, arg1: string | unknown[]) => boolean;
102
90
  notMatches: (value: string, regex: string | RegExp) => boolean;
103
- numberEquals: typeof numberEquals;
91
+ numberEquals: typeof import("vest-utils").numberEquals;
104
92
  numberNotEquals: (value: string | number, eq: string | number) => boolean;
105
93
  shorterThan: typeof shorterThan;
106
94
  shorterThanOrEquals: typeof shorterThanOrEquals;
107
95
  startsWith: typeof startsWith;
108
96
  };
109
- type TRules<E = Record<string, unknown>> = n4s.EnforceCustomMatchers<TRules<E> & E> & Record<string, (...args: TArgs) => TRules<E> & E> & {
110
- [P in KBaseRules]: (...args: DropFirst<Parameters<TBaseRules[P]>> | TArgs) => TRules<E> & E;
97
+ type Rules<E = Record<string, unknown>> = n4s.EnforceCustomMatchers<Rules<E> & E> & Record<string, (...args: Args) => Rules<E> & E> & {
98
+ [P in KBaseRules]: (...args: DropFirst<Parameters<BaseRules[P]>> | Args) => Rules<E> & E;
111
99
  };
112
100
  /* eslint-disable @typescript-eslint/no-namespace, @typescript-eslint/no-empty-interface */
113
101
  declare global {
114
102
  namespace n4s {
115
- interface IRules<E> extends TRules<E> {
103
+ interface IRules<E> extends Rules<E> {
116
104
  }
117
105
  }
118
106
  }
119
- type TLazyRules = n4s.IRules<TLazyRuleMethods>;
120
- type TLazy = TLazyRules & TLazyRuleMethods &
107
+ type LazyRules = n4s.IRules<LazyRuleMethods>;
108
+ type Lazy = LazyRules & LazyRuleMethods &
121
109
  // This is a "catch all" hack to make TS happy while not
122
110
  // losing type hints
123
- Record<string, (...args: any[]) => any>;
124
- type TLazyRuleMethods = TLazyRuleRunners & {
125
- message: (message: TLazyMessage) => TLazy;
111
+ Record<string, CB>;
112
+ type LazyRuleMethods = LazyRuleRunners & {
113
+ message: (message: LazyMessage) => Lazy;
126
114
  };
127
- type TLazyRuleRunners = {
115
+ type LazyRuleRunners = {
128
116
  test: (value: unknown) => boolean;
129
- run: (value: unknown) => TRuleDetailedResult;
117
+ run: (value: unknown) => RuleDetailedResult;
130
118
  };
131
- type TLazyMessage = string | ((value: unknown, originalMessage?: TStringable) => string);
132
- declare function allOf(value: unknown, ...rules: TLazy[]): TRuleDetailedResult;
133
- declare function anyOf(value: unknown, ...rules: TLazy[]): TRuleDetailedResult;
134
- declare function noneOf(value: unknown, ...rules: TLazy[]): TRuleDetailedResult;
135
- declare function oneOf(value: unknown, ...rules: TLazy[]): TRuleDetailedResult;
119
+ type LazyMessage = DynamicValue<string, [
120
+ value: unknown,
121
+ originalMessage?: Stringable
122
+ ]>;
123
+ type EnforceCompoundRule = (value: unknown, ...rules: Lazy[]) => RuleDetailedResult;
136
124
  declare global {
137
125
  namespace n4s {
138
126
  interface EnforceCustomMatchers<R> {
139
- allOf: (...args: DropFirst<Parameters<typeof allOf>>) => R;
140
- anyOf: (...args: DropFirst<Parameters<typeof anyOf>>) => R;
141
- noneOf: (...args: DropFirst<Parameters<typeof noneOf>>) => R;
142
- oneOf: (...args: DropFirst<Parameters<typeof oneOf>>) => R;
127
+ allOf: EnforceCustomMatcher<EnforceCompoundRule, R>;
128
+ anyOf: EnforceCustomMatcher<EnforceCompoundRule, R>;
129
+ noneOf: EnforceCustomMatcher<EnforceCompoundRule, R>;
130
+ oneOf: EnforceCustomMatcher<EnforceCompoundRule, R>;
143
131
  }
144
132
  }
145
133
  }
146
- export {};
134
+ //# sourceMappingURL=compounds.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"compounds.d.ts","sourceRoot":"","sources":["../src/exports/compounds.ts","../src/runtime/enforceContext.ts","../src/lib/ruleReturn.ts","../src/rules/endsWith.ts","../src/rules/equals.ts","../src/rules/greaterThanOrEquals.ts","../src/rules/inside.ts","../src/rules/lessThan.ts","../src/rules/lessThanOrEquals.ts","../src/rules/isBetween.ts","../src/rules/isBlank.ts","../src/rules/isBoolean.ts","../src/rules/isEven.ts","../src/rules/isKeyOf.ts","../src/rules/isNaN.ts","../src/rules/isNegative.ts","../src/rules/isNumber.ts","../src/rules/isOdd.ts","../src/rules/isString.ts","../src/rules/isTruthy.ts","../src/rules/isValueOf.ts","../src/rules/longerThanOrEquals.ts","../src/rules/matches.ts","../src/rules/ruleCondition.ts","../src/rules/shorterThan.ts","../src/rules/shorterThanOrEquals.ts","../src/rules/startsWith.ts","../src/runtime/rules.ts","../src/runtime/runtimeRules.ts","../src/lib/transformResult.ts","../src/runtime/genEnforceLazy.ts","../src/lib/runLazyRule.ts","../src/plugins/compounds/allOf.ts","../src/plugins/compounds/anyOf.ts","../src/lib/enforceUtilityTypes.ts","../src/plugins/compounds/noneOf.ts","../src/plugins/compounds/oneOf.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAYA,KAAK,mBAAmB,GAAG,CACzB,KAAK,EAAE,OAAO,EACd,GAAG,KAAK,EAAE,IAAI,EAAE,KACb,kBAAkB,CAAC;AAGxB,QAAQ,MAAM,CAAC;IACb,UAAU,GAAG,CAAC;QACZ,UAAU,qBAAqB,CAAC,CAAC;YAC/B,KAAK,EAAE,oBAAoB,CAAC,mBAAmB,EAAE,CAAC,CAAC,CAAC;YACpD,KAAK,EAAE,oBAAoB,CAAC,mBAAmB,EAAE,CAAC,CAAC,CAAC;YACpD,MAAM,EAAE,oBAAoB,CAAC,mBAAmB,EAAE,CAAC,CAAC,CAAC;YACrD,KAAK,EAAE,oBAAoB,CAAC,mBAAmB,EAAE,CAAC,CAAC,CAAC;SACrD;KACF;CACF"}
@@ -0,0 +1,18 @@
1
+ /// <reference types="validator" />
2
+ import isAfter from 'validator/es/lib/isAfter';
3
+ import isBefore from 'validator/es/lib/isBefore';
4
+ import isDate from 'validator/es/lib/isDate';
5
+ import isISO8601 from 'validator/es/lib/isISO8601';
6
+ import { CB, DropFirst } from "vest-utils";
7
+ type EnforceCustomMatcher<F extends CB, R> = (...args: DropFirst<Parameters<F>>) => R;
8
+ declare global {
9
+ namespace n4s {
10
+ interface EnforceCustomMatchers<R> {
11
+ isAfter: EnforceCustomMatcher<typeof isAfter, R>;
12
+ isBefore: EnforceCustomMatcher<typeof isBefore, R>;
13
+ isDate: EnforceCustomMatcher<typeof isDate, R>;
14
+ isISO8601: EnforceCustomMatcher<typeof isISO8601, R>;
15
+ }
16
+ }
17
+ }
18
+ //# sourceMappingURL=date.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"date.d.ts","sourceRoot":"","sources":["../src/exports/date.ts","../src/lib/enforceUtilityTypes.ts"],"names":[],"mappings":";AACA,OAAO,OAAO,MAAM,0BAA0B,CAAC;AAC/C,OAAO,QAAQ,MAAM,2BAA2B,CAAC;AACjD,OAAO,MAAM,MAAM,yBAAyB,CAAC;AAC7C,OAAO,SAAS,MAAM,4BAA4B,CAAC;;;AAOnD,QAAQ,MAAM,CAAC;IACb,UAAU,GAAG,CAAC;QACZ,UAAU,qBAAqB,CAAC,CAAC;YAC/B,OAAO,EAAE,oBAAoB,CAAC,OAAO,OAAO,EAAE,CAAC,CAAC,CAAC;YACjD,QAAQ,EAAE,oBAAoB,CAAC,OAAO,QAAQ,EAAE,CAAC,CAAC,CAAC;YACnD,MAAM,EAAE,oBAAoB,CAAC,OAAO,MAAM,EAAE,CAAC,CAAC,CAAC;YAC/C,SAAS,EAAE,oBAAoB,CAAC,OAAO,SAAS,EAAE,CAAC,CAAC,CAAC;SACtD;KACF;CACF"}
@@ -0,0 +1,12 @@
1
+ /// <reference types="validator" />
2
+ import isEmail from 'validator/es/lib/isEmail';
3
+ import { CB, DropFirst } from "vest-utils";
4
+ type EnforceCustomMatcher<F extends CB, R> = (...args: DropFirst<Parameters<F>>) => R;
5
+ declare global {
6
+ namespace n4s {
7
+ interface EnforceCustomMatchers<R> {
8
+ isEmail: EnforceCustomMatcher<typeof isEmail, R>;
9
+ }
10
+ }
11
+ }
12
+ //# sourceMappingURL=email.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"email.d.ts","sourceRoot":"","sources":["../src/exports/email.ts","../src/lib/enforceUtilityTypes.ts"],"names":[],"mappings":";AACA,OAAO,OAAO,MAAM,0BAA0B,CAAC;;;AAO/C,QAAQ,MAAM,CAAC;IACb,UAAU,GAAG,CAAC;QACZ,UAAU,qBAAqB,CAAC,CAAC;YAC/B,OAAO,EAAE,oBAAoB,CAAC,OAAO,OAAO,EAAE,CAAC,CAAC,CAAC;SAClD;KACF;CACF"}
@@ -0,0 +1,12 @@
1
+ /// <reference types="validator" />
2
+ import isURL from 'validator/es/lib/isURL';
3
+ import { CB, DropFirst } from "vest-utils";
4
+ type EnforceCustomMatcher<F extends CB, R> = (...args: DropFirst<Parameters<F>>) => R;
5
+ declare global {
6
+ namespace n4s {
7
+ interface EnforceCustomMatchers<R> {
8
+ isURL: EnforceCustomMatcher<typeof isURL, R>;
9
+ }
10
+ }
11
+ }
12
+ //# sourceMappingURL=isURL.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"isURL.d.ts","sourceRoot":"","sources":["../src/exports/isURL.ts","../src/lib/enforceUtilityTypes.ts"],"names":[],"mappings":";AACA,OAAO,KAAK,MAAM,wBAAwB,CAAC;;;AAO3C,QAAQ,MAAM,CAAC;IACb,UAAU,GAAG,CAAC;QACZ,UAAU,qBAAqB,CAAC,CAAC;YAC/B,KAAK,EAAE,oBAAoB,CAAC,OAAO,KAAK,EAAE,CAAC,CAAC,CAAC;SAC9C;KACF;CACF"}