vest 4.6.1 → 4.6.2-dev-fcaa09
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.
- package/dist/cjs/enforce_compose.development.js +2 -0
- package/dist/cjs/enforce_compose.js +7 -0
- package/dist/cjs/enforce_compose.production.js +1 -0
- package/dist/cjs/enforce_compounds.development.js +4 -0
- package/dist/cjs/enforce_compounds.js +7 -0
- package/dist/cjs/enforce_compounds.production.js +1 -0
- package/dist/cjs/enforce_schema.development.js +4 -0
- package/dist/cjs/enforce_schema.js +7 -0
- package/dist/cjs/enforce_schema.production.js +1 -0
- package/dist/cjs/vest.development.js +4 -74
- package/dist/cjs/vest.production.js +1 -1
- package/dist/es/enforce_compose.development.js +1 -0
- package/dist/es/enforce_compose.production.js +1 -0
- package/dist/es/enforce_compounds.development.js +1 -0
- package/dist/es/enforce_compounds.production.js +1 -0
- package/dist/es/enforce_schema.development.js +1 -0
- package/dist/es/enforce_schema.production.js +1 -0
- package/dist/es/vest.development.js +4 -74
- package/dist/es/vest.production.js +1 -1
- package/dist/umd/enforce_compose.development.js +8 -0
- package/dist/umd/enforce_compose.production.js +1 -0
- package/dist/umd/enforce_compounds.development.js +8 -0
- package/dist/umd/enforce_compounds.production.js +1 -0
- package/dist/umd/enforce_schema.development.js +8 -0
- package/dist/umd/enforce_schema.production.js +1 -0
- package/dist/umd/vest.development.js +7 -78
- package/dist/umd/vest.production.js +1 -1
- package/enforce_compose/package.json +9 -0
- package/enforce_compounds/package.json +9 -0
- package/enforce_schema/package.json +9 -0
- package/package.json +80 -79
- package/tsconfig.json +85 -1
- package/types/classnames.d.ts +1 -0
- package/types/classnames.d.ts.map +1 -0
- package/types/enforce_compose.d.ts +2 -0
- package/types/enforce_compose.d.ts.map +1 -0
- package/types/enforce_compounds.d.ts +2 -0
- package/types/enforce_compounds.d.ts.map +1 -0
- package/types/enforce_schema.d.ts +2 -0
- package/types/enforce_schema.d.ts.map +1 -0
- package/types/parser.d.ts +1 -0
- package/types/parser.d.ts.map +1 -0
- package/types/promisify.d.ts +1 -0
- package/types/promisify.d.ts.map +1 -0
- package/types/vest.d.ts +5 -10
- package/types/vest.d.ts.map +1 -0
- package/dist/cjs/compose.js +0 -7
- package/dist/cjs/compounds.js +0 -7
- package/dist/cjs/enforce/compose.development.js +0 -60
- package/dist/cjs/enforce/compose.production.js +0 -1
- package/dist/cjs/enforce/compounds.development.js +0 -92
- package/dist/cjs/enforce/compounds.production.js +0 -1
- package/dist/cjs/enforce/package.json +0 -1
- package/dist/cjs/enforce/schema.development.js +0 -92
- package/dist/cjs/enforce/schema.production.js +0 -1
- package/dist/cjs/schema.js +0 -7
- package/dist/es/enforce/compose.development.js +0 -58
- package/dist/es/enforce/compose.production.js +0 -1
- package/dist/es/enforce/compounds.development.js +0 -90
- package/dist/es/enforce/compounds.production.js +0 -1
- package/dist/es/enforce/package.json +0 -1
- package/dist/es/enforce/schema.development.js +0 -88
- package/dist/es/enforce/schema.production.js +0 -1
- package/dist/umd/enforce/compose.development.js +0 -63
- package/dist/umd/enforce/compose.production.js +0 -1
- package/dist/umd/enforce/compounds.development.js +0 -95
- package/dist/umd/enforce/compounds.production.js +0 -1
- package/dist/umd/enforce/schema.development.js +0 -95
- package/dist/umd/enforce/schema.production.js +0 -1
- package/enforce/compose/package.json +0 -9
- package/enforce/compounds/package.json +0 -9
- package/enforce/schema/package.json +0 -9
- package/types/enforce/compose.d.ts +0 -126
- package/types/enforce/compounds.d.ts +0 -136
- package/types/enforce/schema.d.ts +0 -144
|
@@ -1,95 +0,0 @@
|
|
|
1
|
-
(function (global, factory) {
|
|
2
|
-
typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('n4s'), require('vest-utils')) :
|
|
3
|
-
typeof define === 'function' && define.amd ? define(['exports', 'n4s', 'vest-utils'], factory) :
|
|
4
|
-
(global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global.schema = {}, global.n4s, global['vest-utils']));
|
|
5
|
-
}(this, (function (exports, n4s, vestUtils) { 'use strict';
|
|
6
|
-
|
|
7
|
-
function ruleReturn(pass, message) {
|
|
8
|
-
var output = { pass: pass };
|
|
9
|
-
if (message) {
|
|
10
|
-
output.message = message;
|
|
11
|
-
}
|
|
12
|
-
return output;
|
|
13
|
-
}
|
|
14
|
-
function failing() {
|
|
15
|
-
return ruleReturn(false);
|
|
16
|
-
}
|
|
17
|
-
function passing() {
|
|
18
|
-
return ruleReturn(true);
|
|
19
|
-
}
|
|
20
|
-
function defaultToPassing(callback) {
|
|
21
|
-
return vestUtils.defaultTo(callback, passing());
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
function runLazyRule(lazyRule, currentValue) {
|
|
25
|
-
try {
|
|
26
|
-
return lazyRule.run(currentValue);
|
|
27
|
-
}
|
|
28
|
-
catch (_a) {
|
|
29
|
-
return failing();
|
|
30
|
-
}
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
function isArrayOf(inputArray, currentRule) {
|
|
34
|
-
return defaultToPassing(vestUtils.mapFirst(inputArray, function (currentValue, breakout, index) {
|
|
35
|
-
var res = n4s.ctx.run({ value: currentValue, set: true, meta: { index: index } }, function () { return runLazyRule(currentRule, currentValue); });
|
|
36
|
-
breakout(!res.pass, res);
|
|
37
|
-
}));
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
function loose(inputObject, shapeObject) {
|
|
41
|
-
var _loop_1 = function (key) {
|
|
42
|
-
var currentValue = inputObject[key];
|
|
43
|
-
var currentRule = shapeObject[key];
|
|
44
|
-
var res = n4s.ctx.run({ value: currentValue, set: true, meta: { key: key } }, function () {
|
|
45
|
-
return runLazyRule(currentRule, currentValue);
|
|
46
|
-
});
|
|
47
|
-
if (!res.pass) {
|
|
48
|
-
return { value: res };
|
|
49
|
-
}
|
|
50
|
-
};
|
|
51
|
-
for (var key in shapeObject) {
|
|
52
|
-
var state_1 = _loop_1(key);
|
|
53
|
-
if (typeof state_1 === "object")
|
|
54
|
-
return state_1.value;
|
|
55
|
-
}
|
|
56
|
-
return passing();
|
|
57
|
-
}
|
|
58
|
-
|
|
59
|
-
function optional(value, ruleChain) {
|
|
60
|
-
if (vestUtils.isNullish(value)) {
|
|
61
|
-
return passing();
|
|
62
|
-
}
|
|
63
|
-
return runLazyRule(ruleChain, value);
|
|
64
|
-
}
|
|
65
|
-
|
|
66
|
-
function shape(inputObject, shapeObject) {
|
|
67
|
-
var baseRes = loose(inputObject, shapeObject);
|
|
68
|
-
if (!baseRes.pass) {
|
|
69
|
-
return baseRes;
|
|
70
|
-
}
|
|
71
|
-
for (var key in inputObject) {
|
|
72
|
-
if (!vestUtils.hasOwnProperty(shapeObject, key)) {
|
|
73
|
-
return failing();
|
|
74
|
-
}
|
|
75
|
-
}
|
|
76
|
-
return passing();
|
|
77
|
-
}
|
|
78
|
-
|
|
79
|
-
// Help needed improving the typings of this file.
|
|
80
|
-
// Ideally, we'd be able to extend ShapeObject, but that's not possible.
|
|
81
|
-
function partial(shapeObject) {
|
|
82
|
-
var output = {};
|
|
83
|
-
for (var key in shapeObject) {
|
|
84
|
-
output[key] = n4s.enforce.optional(shapeObject[key]);
|
|
85
|
-
}
|
|
86
|
-
return output;
|
|
87
|
-
}
|
|
88
|
-
|
|
89
|
-
n4s.enforce.extend({ isArrayOf: isArrayOf, loose: loose, optional: optional, shape: shape });
|
|
90
|
-
|
|
91
|
-
exports.partial = partial;
|
|
92
|
-
|
|
93
|
-
Object.defineProperty(exports, '__esModule', { value: true });
|
|
94
|
-
|
|
95
|
-
})));
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
"use strict";!function(e,n){"object"==typeof exports&&"undefined"!=typeof module?n(exports,require("n4s"),require("vest-utils")):"function"==typeof define&&define.amd?define(["exports","n4s","vest-utils"],n):n((e="undefined"!=typeof globalThis?globalThis:e||self).schema={},e.n4s,e["vest-utils"])}(this,(function(e,n,t){function r(e,n){return e={pass:e},n&&(e.message=n),e}function u(e,n){try{return e.run(n)}catch(e){return r(!1)}}function i(e,t){var i,o=function(r){var i=e[r],o=t[r];if(!(r=n.ctx.run({value:i,set:!0,meta:{key:r}},(function(){return u(o,i)}))).pass)return{value:r}};for(i in t){var s=o(i);if("object"==typeof s)return s.value}return r(!0)}n.enforce.extend({isArrayOf:function(e,i){return t.defaultTo(t.mapFirst(e,(function(e,t,r){t(!(r=n.ctx.run({value:e,set:!0,meta:{index:r}},(function(){return u(i,e)}))).pass,r)})),r(!0))},loose:i,optional:function(e,n){return t.isNullish(e)?r(!0):u(n,e)},shape:function(e,n){var u=i(e,n);if(!u.pass)return u;for(var o in e)if(!t.hasOwnProperty(n,o))return r(!1);return r(!0)}}),e.partial=function(e){var t,r={};for(t in e)r[t]=n.enforce.optional(e[t]);return r},Object.defineProperty(e,"__esModule",{value:!0})}));
|
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"main": "../../dist/cjs/enforce/compose.js",
|
|
3
|
-
"module": "../../dist/es/enforce/compose.production.js",
|
|
4
|
-
"unpkg": "../../dist/umd/enforce/compose.production.js",
|
|
5
|
-
"jsdelivr": "../../dist/umd/enforce/compose.production.js",
|
|
6
|
-
"name": "compose",
|
|
7
|
-
"types": "../../types/enforce/compose.d.ts",
|
|
8
|
-
"private": true
|
|
9
|
-
}
|
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"main": "../../dist/cjs/enforce/compounds.js",
|
|
3
|
-
"module": "../../dist/es/enforce/compounds.production.js",
|
|
4
|
-
"unpkg": "../../dist/umd/enforce/compounds.production.js",
|
|
5
|
-
"jsdelivr": "../../dist/umd/enforce/compounds.production.js",
|
|
6
|
-
"name": "compounds",
|
|
7
|
-
"types": "../../types/enforce/compounds.d.ts",
|
|
8
|
-
"private": true
|
|
9
|
-
}
|
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"main": "../../dist/cjs/enforce/schema.js",
|
|
3
|
-
"module": "../../dist/es/enforce/schema.production.js",
|
|
4
|
-
"unpkg": "../../dist/umd/enforce/schema.production.js",
|
|
5
|
-
"jsdelivr": "../../dist/umd/enforce/schema.production.js",
|
|
6
|
-
"name": "schema",
|
|
7
|
-
"types": "../../types/enforce/schema.d.ts",
|
|
8
|
-
"private": true
|
|
9
|
-
}
|
|
@@ -1,126 +0,0 @@
|
|
|
1
|
-
type DropFirst<T extends unknown[]> = T extends [
|
|
2
|
-
unknown,
|
|
3
|
-
...infer U
|
|
4
|
-
] ? U : never;
|
|
5
|
-
type Stringable = string | ((...args: any[]) => string);
|
|
6
|
-
type CB = (...args: any[]) => any;
|
|
7
|
-
type RuleReturn = boolean | {
|
|
8
|
-
pass: boolean;
|
|
9
|
-
message?: Stringable;
|
|
10
|
-
};
|
|
11
|
-
type RuleDetailedResult = {
|
|
12
|
-
pass: boolean;
|
|
13
|
-
message?: string;
|
|
14
|
-
};
|
|
15
|
-
type Args = any[];
|
|
16
|
-
type BaseRules = typeof baseRules;
|
|
17
|
-
type KBaseRules = keyof BaseRules;
|
|
18
|
-
declare function condition(value: any, callback: (value: any) => RuleReturn): RuleReturn;
|
|
19
|
-
declare function endsWith(value: string, arg1: string): boolean;
|
|
20
|
-
declare function equals(value: unknown, arg1: unknown): boolean;
|
|
21
|
-
declare function greaterThanOrEquals(value: string | number, gte: string | number): boolean;
|
|
22
|
-
declare function inside(value: unknown, arg1: string | unknown[]): boolean;
|
|
23
|
-
declare function isBetween(value: number | string, min: number | string, max: number | string): boolean;
|
|
24
|
-
declare function isBlank(value: unknown): boolean;
|
|
25
|
-
declare function isKeyOf(key: string | symbol | number, obj: any): boolean;
|
|
26
|
-
declare function isNaN(value: unknown): boolean;
|
|
27
|
-
declare function isNegative(value: number | string): boolean;
|
|
28
|
-
declare function isNumber(value: unknown): value is number;
|
|
29
|
-
declare function isTruthy(value: unknown): boolean;
|
|
30
|
-
declare function isValueOf(value: any, objectToCheck: any): boolean;
|
|
31
|
-
declare function lessThan(value: string | number, lt: string | number): boolean;
|
|
32
|
-
declare function lessThanOrEquals(value: string | number, lte: string | number): boolean;
|
|
33
|
-
declare function longerThanOrEquals(value: string | unknown[], arg1: string | number): boolean;
|
|
34
|
-
declare function matches(value: string, regex: RegExp | string): boolean;
|
|
35
|
-
declare function shorterThan(value: string | unknown[], arg1: string | number): boolean;
|
|
36
|
-
declare function shorterThanOrEquals(value: string | unknown[], arg1: string | number): boolean;
|
|
37
|
-
declare function startsWith(value: string, arg1: string): boolean;
|
|
38
|
-
declare const baseRules: {
|
|
39
|
-
condition: typeof condition;
|
|
40
|
-
doesNotEndWith: (value: string, arg1: string) => boolean;
|
|
41
|
-
doesNotStartWith: (value: string, arg1: string) => boolean;
|
|
42
|
-
endsWith: typeof endsWith;
|
|
43
|
-
equals: typeof equals;
|
|
44
|
-
greaterThan: typeof import("packages/vest-utils/types/vest-utils").greaterThan;
|
|
45
|
-
greaterThanOrEquals: typeof greaterThanOrEquals;
|
|
46
|
-
gt: typeof import("packages/vest-utils/types/vest-utils").greaterThan;
|
|
47
|
-
gte: typeof greaterThanOrEquals;
|
|
48
|
-
inside: typeof inside;
|
|
49
|
-
isArray: typeof import("packages/vest-utils/types/vest-utils").isArray;
|
|
50
|
-
isBetween: typeof isBetween;
|
|
51
|
-
isBlank: typeof isBlank;
|
|
52
|
-
isBoolean: typeof import("packages/vest-utils/types/vest-utils").isBoolean;
|
|
53
|
-
isEmpty: typeof import("packages/vest-utils/types/vest-utils").isEmpty;
|
|
54
|
-
isEven: (value: any) => boolean;
|
|
55
|
-
isFalsy: (value: unknown) => boolean;
|
|
56
|
-
isKeyOf: typeof isKeyOf;
|
|
57
|
-
isNaN: typeof isNaN;
|
|
58
|
-
isNegative: typeof isNegative;
|
|
59
|
-
isNotArray: (value: unknown) => boolean;
|
|
60
|
-
isNotBetween: (value: string | number, min: string | number, max: string | number) => boolean;
|
|
61
|
-
isNotBlank: (value: unknown) => boolean;
|
|
62
|
-
isNotBoolean: (value: unknown) => boolean;
|
|
63
|
-
isNotEmpty: (value: unknown) => boolean;
|
|
64
|
-
isNotKeyOf: (key: string | number | symbol, obj: any) => boolean;
|
|
65
|
-
isNotNaN: (value: unknown) => boolean;
|
|
66
|
-
isNotNull: (value: unknown) => boolean;
|
|
67
|
-
isNotNullish: (value: any) => boolean;
|
|
68
|
-
isNotNumber: (value: unknown) => boolean;
|
|
69
|
-
isNotNumeric: (value: string | number) => boolean;
|
|
70
|
-
isNotString: (v: unknown) => boolean;
|
|
71
|
-
isNotUndefined: (value?: unknown) => boolean;
|
|
72
|
-
isNotValueOf: (value: any, objectToCheck: any) => boolean;
|
|
73
|
-
isNull: typeof import("packages/vest-utils/types/vest-utils").isNull;
|
|
74
|
-
isNullish: typeof import("packages/vest-utils/types/vest-utils").isNullish;
|
|
75
|
-
isNumber: typeof isNumber;
|
|
76
|
-
isNumeric: typeof import("packages/vest-utils/types/vest-utils").isNumeric;
|
|
77
|
-
isOdd: (value: any) => boolean;
|
|
78
|
-
isPositive: typeof import("packages/vest-utils/types/vest-utils").isPositive;
|
|
79
|
-
isString: typeof import("packages/vest-utils/types/vest-utils").isStringValue;
|
|
80
|
-
isTruthy: typeof isTruthy;
|
|
81
|
-
isUndefined: typeof import("packages/vest-utils/types/vest-utils").isUndefined;
|
|
82
|
-
isValueOf: typeof isValueOf;
|
|
83
|
-
lengthEquals: typeof import("packages/vest-utils/types/vest-utils").lengthEquals;
|
|
84
|
-
lengthNotEquals: (value: string | unknown[], arg1: string | number) => boolean;
|
|
85
|
-
lessThan: typeof lessThan;
|
|
86
|
-
lessThanOrEquals: typeof lessThanOrEquals;
|
|
87
|
-
longerThan: typeof import("packages/vest-utils/types/vest-utils").longerThan;
|
|
88
|
-
longerThanOrEquals: typeof longerThanOrEquals;
|
|
89
|
-
lt: typeof lessThan;
|
|
90
|
-
lte: typeof lessThanOrEquals;
|
|
91
|
-
matches: typeof matches;
|
|
92
|
-
notEquals: (value: unknown, arg1: unknown) => boolean;
|
|
93
|
-
notInside: (value: unknown, arg1: string | unknown[]) => boolean;
|
|
94
|
-
notMatches: (value: string, regex: string | RegExp) => boolean;
|
|
95
|
-
numberEquals: typeof import("packages/vest-utils/types/vest-utils").numberEquals;
|
|
96
|
-
numberNotEquals: (value: string | number, eq: string | number) => boolean;
|
|
97
|
-
shorterThan: typeof shorterThan;
|
|
98
|
-
shorterThanOrEquals: typeof shorterThanOrEquals;
|
|
99
|
-
startsWith: typeof startsWith;
|
|
100
|
-
};
|
|
101
|
-
type Rules<E> = n4s.EnforceCustomMatchers<Rules<E> & E> & Record<string, (...args: Args) => Rules<E> & E> & {
|
|
102
|
-
[P in KBaseRules]: (...args: DropFirst<Parameters<BaseRules[P]>> | Args) => Rules<E> & E;
|
|
103
|
-
};
|
|
104
|
-
/* eslint-disable @typescript-eslint/no-namespace, @typescript-eslint/no-empty-interface */
|
|
105
|
-
declare global {
|
|
106
|
-
namespace n4s {
|
|
107
|
-
interface IRules<E> extends Rules<E> {
|
|
108
|
-
}
|
|
109
|
-
}
|
|
110
|
-
}
|
|
111
|
-
type LazyRules = n4s.IRules<LazyRuleMethods>;
|
|
112
|
-
type Lazy = LazyRules & LazyRuleMethods &
|
|
113
|
-
// This is a "catch all" hack to make TS happy while not
|
|
114
|
-
// losing type hints
|
|
115
|
-
Record<string, CB>;
|
|
116
|
-
type LazyRuleMethods = LazyRuleRunners & {
|
|
117
|
-
message: (message: LazyMessage) => Lazy;
|
|
118
|
-
};
|
|
119
|
-
type LazyRuleRunners = {
|
|
120
|
-
test: (value: unknown) => boolean;
|
|
121
|
-
run: (value: unknown) => RuleDetailedResult;
|
|
122
|
-
};
|
|
123
|
-
type ComposeResult = LazyRuleRunners & ((value: any) => void);
|
|
124
|
-
type LazyMessage = string | ((value: unknown, originalMessage?: Stringable) => string);
|
|
125
|
-
declare function compose(...composites: LazyRuleRunners[]): ComposeResult;
|
|
126
|
-
export { compose as default };
|
|
@@ -1,136 +0,0 @@
|
|
|
1
|
-
type DropFirst<T extends unknown[]> = T extends [
|
|
2
|
-
unknown,
|
|
3
|
-
...infer U
|
|
4
|
-
] ? U : never;
|
|
5
|
-
type Stringable = string | ((...args: any[]) => string);
|
|
6
|
-
type CB = (...args: any[]) => any;
|
|
7
|
-
type EnforceCustomMatcher<F extends CB, R> = (...args: DropFirst<Parameters<F>>) => R;
|
|
8
|
-
type RuleReturn = boolean | {
|
|
9
|
-
pass: boolean;
|
|
10
|
-
message?: Stringable;
|
|
11
|
-
};
|
|
12
|
-
type RuleDetailedResult = {
|
|
13
|
-
pass: boolean;
|
|
14
|
-
message?: string;
|
|
15
|
-
};
|
|
16
|
-
type Args = any[];
|
|
17
|
-
type BaseRules = typeof baseRules;
|
|
18
|
-
type KBaseRules = keyof BaseRules;
|
|
19
|
-
declare function condition(value: any, callback: (value: any) => RuleReturn): RuleReturn;
|
|
20
|
-
declare function endsWith(value: string, arg1: string): boolean;
|
|
21
|
-
declare function equals(value: unknown, arg1: unknown): boolean;
|
|
22
|
-
declare function greaterThanOrEquals(value: string | number, gte: string | number): boolean;
|
|
23
|
-
declare function inside(value: unknown, arg1: string | unknown[]): boolean;
|
|
24
|
-
declare function isBetween(value: number | string, min: number | string, max: number | string): boolean;
|
|
25
|
-
declare function isBlank(value: unknown): boolean;
|
|
26
|
-
declare function isKeyOf(key: string | symbol | number, obj: any): boolean;
|
|
27
|
-
declare function isNaN(value: unknown): boolean;
|
|
28
|
-
declare function isNegative(value: number | string): boolean;
|
|
29
|
-
declare function isNumber(value: unknown): value is number;
|
|
30
|
-
declare function isTruthy(value: unknown): boolean;
|
|
31
|
-
declare function isValueOf(value: any, objectToCheck: any): boolean;
|
|
32
|
-
declare function lessThan(value: string | number, lt: string | number): boolean;
|
|
33
|
-
declare function lessThanOrEquals(value: string | number, lte: string | number): boolean;
|
|
34
|
-
declare function longerThanOrEquals(value: string | unknown[], arg1: string | number): boolean;
|
|
35
|
-
declare function matches(value: string, regex: RegExp | string): boolean;
|
|
36
|
-
declare function shorterThan(value: string | unknown[], arg1: string | number): boolean;
|
|
37
|
-
declare function shorterThanOrEquals(value: string | unknown[], arg1: string | number): boolean;
|
|
38
|
-
declare function startsWith(value: string, arg1: string): boolean;
|
|
39
|
-
declare const baseRules: {
|
|
40
|
-
condition: typeof condition;
|
|
41
|
-
doesNotEndWith: (value: string, arg1: string) => boolean;
|
|
42
|
-
doesNotStartWith: (value: string, arg1: string) => boolean;
|
|
43
|
-
endsWith: typeof endsWith;
|
|
44
|
-
equals: typeof equals;
|
|
45
|
-
greaterThan: typeof import("packages/vest-utils/types/vest-utils").greaterThan;
|
|
46
|
-
greaterThanOrEquals: typeof greaterThanOrEquals;
|
|
47
|
-
gt: typeof import("packages/vest-utils/types/vest-utils").greaterThan;
|
|
48
|
-
gte: typeof greaterThanOrEquals;
|
|
49
|
-
inside: typeof inside;
|
|
50
|
-
isArray: typeof import("packages/vest-utils/types/vest-utils").isArray;
|
|
51
|
-
isBetween: typeof isBetween;
|
|
52
|
-
isBlank: typeof isBlank;
|
|
53
|
-
isBoolean: typeof import("packages/vest-utils/types/vest-utils").isBoolean;
|
|
54
|
-
isEmpty: typeof import("packages/vest-utils/types/vest-utils").isEmpty;
|
|
55
|
-
isEven: (value: any) => boolean;
|
|
56
|
-
isFalsy: (value: unknown) => boolean;
|
|
57
|
-
isKeyOf: typeof isKeyOf;
|
|
58
|
-
isNaN: typeof isNaN;
|
|
59
|
-
isNegative: typeof isNegative;
|
|
60
|
-
isNotArray: (value: unknown) => boolean;
|
|
61
|
-
isNotBetween: (value: string | number, min: string | number, max: string | number) => boolean;
|
|
62
|
-
isNotBlank: (value: unknown) => boolean;
|
|
63
|
-
isNotBoolean: (value: unknown) => boolean;
|
|
64
|
-
isNotEmpty: (value: unknown) => boolean;
|
|
65
|
-
isNotKeyOf: (key: string | number | symbol, obj: any) => boolean;
|
|
66
|
-
isNotNaN: (value: unknown) => boolean;
|
|
67
|
-
isNotNull: (value: unknown) => boolean;
|
|
68
|
-
isNotNullish: (value: any) => boolean;
|
|
69
|
-
isNotNumber: (value: unknown) => boolean;
|
|
70
|
-
isNotNumeric: (value: string | number) => boolean;
|
|
71
|
-
isNotString: (v: unknown) => boolean;
|
|
72
|
-
isNotUndefined: (value?: unknown) => boolean;
|
|
73
|
-
isNotValueOf: (value: any, objectToCheck: any) => boolean;
|
|
74
|
-
isNull: typeof import("packages/vest-utils/types/vest-utils").isNull;
|
|
75
|
-
isNullish: typeof import("packages/vest-utils/types/vest-utils").isNullish;
|
|
76
|
-
isNumber: typeof isNumber;
|
|
77
|
-
isNumeric: typeof import("packages/vest-utils/types/vest-utils").isNumeric;
|
|
78
|
-
isOdd: (value: any) => boolean;
|
|
79
|
-
isPositive: typeof import("packages/vest-utils/types/vest-utils").isPositive;
|
|
80
|
-
isString: typeof import("packages/vest-utils/types/vest-utils").isStringValue;
|
|
81
|
-
isTruthy: typeof isTruthy;
|
|
82
|
-
isUndefined: typeof import("packages/vest-utils/types/vest-utils").isUndefined;
|
|
83
|
-
isValueOf: typeof isValueOf;
|
|
84
|
-
lengthEquals: typeof import("packages/vest-utils/types/vest-utils").lengthEquals;
|
|
85
|
-
lengthNotEquals: (value: string | unknown[], arg1: string | number) => boolean;
|
|
86
|
-
lessThan: typeof lessThan;
|
|
87
|
-
lessThanOrEquals: typeof lessThanOrEquals;
|
|
88
|
-
longerThan: typeof import("packages/vest-utils/types/vest-utils").longerThan;
|
|
89
|
-
longerThanOrEquals: typeof longerThanOrEquals;
|
|
90
|
-
lt: typeof lessThan;
|
|
91
|
-
lte: typeof lessThanOrEquals;
|
|
92
|
-
matches: typeof matches;
|
|
93
|
-
notEquals: (value: unknown, arg1: unknown) => boolean;
|
|
94
|
-
notInside: (value: unknown, arg1: string | unknown[]) => boolean;
|
|
95
|
-
notMatches: (value: string, regex: string | RegExp) => boolean;
|
|
96
|
-
numberEquals: typeof import("packages/vest-utils/types/vest-utils").numberEquals;
|
|
97
|
-
numberNotEquals: (value: string | number, eq: string | number) => boolean;
|
|
98
|
-
shorterThan: typeof shorterThan;
|
|
99
|
-
shorterThanOrEquals: typeof shorterThanOrEquals;
|
|
100
|
-
startsWith: typeof startsWith;
|
|
101
|
-
};
|
|
102
|
-
type Rules<E> = n4s.EnforceCustomMatchers<Rules<E> & E> & Record<string, (...args: Args) => Rules<E> & E> & {
|
|
103
|
-
[P in KBaseRules]: (...args: DropFirst<Parameters<BaseRules[P]>> | Args) => Rules<E> & E;
|
|
104
|
-
};
|
|
105
|
-
/* eslint-disable @typescript-eslint/no-namespace, @typescript-eslint/no-empty-interface */
|
|
106
|
-
declare global {
|
|
107
|
-
namespace n4s {
|
|
108
|
-
interface IRules<E> extends Rules<E> {
|
|
109
|
-
}
|
|
110
|
-
}
|
|
111
|
-
}
|
|
112
|
-
type LazyRules = n4s.IRules<LazyRuleMethods>;
|
|
113
|
-
type Lazy = LazyRules & LazyRuleMethods &
|
|
114
|
-
// This is a "catch all" hack to make TS happy while not
|
|
115
|
-
// losing type hints
|
|
116
|
-
Record<string, CB>;
|
|
117
|
-
type LazyRuleMethods = LazyRuleRunners & {
|
|
118
|
-
message: (message: LazyMessage) => Lazy;
|
|
119
|
-
};
|
|
120
|
-
type LazyRuleRunners = {
|
|
121
|
-
test: (value: unknown) => boolean;
|
|
122
|
-
run: (value: unknown) => RuleDetailedResult;
|
|
123
|
-
};
|
|
124
|
-
type LazyMessage = string | ((value: unknown, originalMessage?: Stringable) => string);
|
|
125
|
-
type EnforceCompoundRule = (value: unknown, ...rules: Lazy[]) => RuleDetailedResult;
|
|
126
|
-
declare global {
|
|
127
|
-
namespace n4s {
|
|
128
|
-
interface EnforceCustomMatchers<R> {
|
|
129
|
-
allOf: EnforceCustomMatcher<EnforceCompoundRule, R>;
|
|
130
|
-
anyOf: EnforceCustomMatcher<EnforceCompoundRule, R>;
|
|
131
|
-
noneOf: EnforceCustomMatcher<EnforceCompoundRule, R>;
|
|
132
|
-
oneOf: EnforceCustomMatcher<EnforceCompoundRule, R>;
|
|
133
|
-
}
|
|
134
|
-
}
|
|
135
|
-
}
|
|
136
|
-
export {};
|
|
@@ -1,144 +0,0 @@
|
|
|
1
|
-
type DropFirst<T extends unknown[]> = T extends [
|
|
2
|
-
unknown,
|
|
3
|
-
...infer U
|
|
4
|
-
] ? U : never;
|
|
5
|
-
type Stringable = string | ((...args: any[]) => string);
|
|
6
|
-
type CB = (...args: any[]) => any;
|
|
7
|
-
type EnforceCustomMatcher<F extends CB, R> = (...args: DropFirst<Parameters<F>>) => R;
|
|
8
|
-
type RuleReturn = boolean | {
|
|
9
|
-
pass: boolean;
|
|
10
|
-
message?: Stringable;
|
|
11
|
-
};
|
|
12
|
-
type RuleDetailedResult = {
|
|
13
|
-
pass: boolean;
|
|
14
|
-
message?: string;
|
|
15
|
-
};
|
|
16
|
-
type Args = any[];
|
|
17
|
-
type BaseRules = typeof baseRules;
|
|
18
|
-
type KBaseRules = keyof BaseRules;
|
|
19
|
-
declare function condition(value: any, callback: (value: any) => RuleReturn): RuleReturn;
|
|
20
|
-
declare function endsWith(value: string, arg1: string): boolean;
|
|
21
|
-
declare function equals(value: unknown, arg1: unknown): boolean;
|
|
22
|
-
declare function greaterThanOrEquals(value: string | number, gte: string | number): boolean;
|
|
23
|
-
declare function inside(value: unknown, arg1: string | unknown[]): boolean;
|
|
24
|
-
declare function isBetween(value: number | string, min: number | string, max: number | string): boolean;
|
|
25
|
-
declare function isBlank(value: unknown): boolean;
|
|
26
|
-
declare function isKeyOf(key: string | symbol | number, obj: any): boolean;
|
|
27
|
-
declare function isNaN(value: unknown): boolean;
|
|
28
|
-
declare function isNegative(value: number | string): boolean;
|
|
29
|
-
declare function isNumber(value: unknown): value is number;
|
|
30
|
-
declare function isTruthy(value: unknown): boolean;
|
|
31
|
-
declare function isValueOf(value: any, objectToCheck: any): boolean;
|
|
32
|
-
declare function lessThan(value: string | number, lt: string | number): boolean;
|
|
33
|
-
declare function lessThanOrEquals(value: string | number, lte: string | number): boolean;
|
|
34
|
-
declare function longerThanOrEquals(value: string | unknown[], arg1: string | number): boolean;
|
|
35
|
-
declare function matches(value: string, regex: RegExp | string): boolean;
|
|
36
|
-
declare function shorterThan(value: string | unknown[], arg1: string | number): boolean;
|
|
37
|
-
declare function shorterThanOrEquals(value: string | unknown[], arg1: string | number): boolean;
|
|
38
|
-
declare function startsWith(value: string, arg1: string): boolean;
|
|
39
|
-
declare const baseRules: {
|
|
40
|
-
condition: typeof condition;
|
|
41
|
-
doesNotEndWith: (value: string, arg1: string) => boolean;
|
|
42
|
-
doesNotStartWith: (value: string, arg1: string) => boolean;
|
|
43
|
-
endsWith: typeof endsWith;
|
|
44
|
-
equals: typeof equals;
|
|
45
|
-
greaterThan: typeof import("packages/vest-utils/types/vest-utils").greaterThan;
|
|
46
|
-
greaterThanOrEquals: typeof greaterThanOrEquals;
|
|
47
|
-
gt: typeof import("packages/vest-utils/types/vest-utils").greaterThan;
|
|
48
|
-
gte: typeof greaterThanOrEquals;
|
|
49
|
-
inside: typeof inside;
|
|
50
|
-
isArray: typeof import("packages/vest-utils/types/vest-utils").isArray;
|
|
51
|
-
isBetween: typeof isBetween;
|
|
52
|
-
isBlank: typeof isBlank;
|
|
53
|
-
isBoolean: typeof import("packages/vest-utils/types/vest-utils").isBoolean;
|
|
54
|
-
isEmpty: typeof import("packages/vest-utils/types/vest-utils").isEmpty;
|
|
55
|
-
isEven: (value: any) => boolean;
|
|
56
|
-
isFalsy: (value: unknown) => boolean;
|
|
57
|
-
isKeyOf: typeof isKeyOf;
|
|
58
|
-
isNaN: typeof isNaN;
|
|
59
|
-
isNegative: typeof isNegative;
|
|
60
|
-
isNotArray: (value: unknown) => boolean;
|
|
61
|
-
isNotBetween: (value: string | number, min: string | number, max: string | number) => boolean;
|
|
62
|
-
isNotBlank: (value: unknown) => boolean;
|
|
63
|
-
isNotBoolean: (value: unknown) => boolean;
|
|
64
|
-
isNotEmpty: (value: unknown) => boolean;
|
|
65
|
-
isNotKeyOf: (key: string | number | symbol, obj: any) => boolean;
|
|
66
|
-
isNotNaN: (value: unknown) => boolean;
|
|
67
|
-
isNotNull: (value: unknown) => boolean;
|
|
68
|
-
isNotNullish: (value: any) => boolean;
|
|
69
|
-
isNotNumber: (value: unknown) => boolean;
|
|
70
|
-
isNotNumeric: (value: string | number) => boolean;
|
|
71
|
-
isNotString: (v: unknown) => boolean;
|
|
72
|
-
isNotUndefined: (value?: unknown) => boolean;
|
|
73
|
-
isNotValueOf: (value: any, objectToCheck: any) => boolean;
|
|
74
|
-
isNull: typeof import("packages/vest-utils/types/vest-utils").isNull;
|
|
75
|
-
isNullish: typeof import("packages/vest-utils/types/vest-utils").isNullish;
|
|
76
|
-
isNumber: typeof isNumber;
|
|
77
|
-
isNumeric: typeof import("packages/vest-utils/types/vest-utils").isNumeric;
|
|
78
|
-
isOdd: (value: any) => boolean;
|
|
79
|
-
isPositive: typeof import("packages/vest-utils/types/vest-utils").isPositive;
|
|
80
|
-
isString: typeof import("packages/vest-utils/types/vest-utils").isStringValue;
|
|
81
|
-
isTruthy: typeof isTruthy;
|
|
82
|
-
isUndefined: typeof import("packages/vest-utils/types/vest-utils").isUndefined;
|
|
83
|
-
isValueOf: typeof isValueOf;
|
|
84
|
-
lengthEquals: typeof import("packages/vest-utils/types/vest-utils").lengthEquals;
|
|
85
|
-
lengthNotEquals: (value: string | unknown[], arg1: string | number) => boolean;
|
|
86
|
-
lessThan: typeof lessThan;
|
|
87
|
-
lessThanOrEquals: typeof lessThanOrEquals;
|
|
88
|
-
longerThan: typeof import("packages/vest-utils/types/vest-utils").longerThan;
|
|
89
|
-
longerThanOrEquals: typeof longerThanOrEquals;
|
|
90
|
-
lt: typeof lessThan;
|
|
91
|
-
lte: typeof lessThanOrEquals;
|
|
92
|
-
matches: typeof matches;
|
|
93
|
-
notEquals: (value: unknown, arg1: unknown) => boolean;
|
|
94
|
-
notInside: (value: unknown, arg1: string | unknown[]) => boolean;
|
|
95
|
-
notMatches: (value: string, regex: string | RegExp) => boolean;
|
|
96
|
-
numberEquals: typeof import("packages/vest-utils/types/vest-utils").numberEquals;
|
|
97
|
-
numberNotEquals: (value: string | number, eq: string | number) => boolean;
|
|
98
|
-
shorterThan: typeof shorterThan;
|
|
99
|
-
shorterThanOrEquals: typeof shorterThanOrEquals;
|
|
100
|
-
startsWith: typeof startsWith;
|
|
101
|
-
};
|
|
102
|
-
type Rules<E> = n4s.EnforceCustomMatchers<Rules<E> & E> & Record<string, (...args: Args) => Rules<E> & E> & {
|
|
103
|
-
[P in KBaseRules]: (...args: DropFirst<Parameters<BaseRules[P]>> | Args) => Rules<E> & E;
|
|
104
|
-
};
|
|
105
|
-
/* eslint-disable @typescript-eslint/no-namespace, @typescript-eslint/no-empty-interface */
|
|
106
|
-
declare global {
|
|
107
|
-
namespace n4s {
|
|
108
|
-
interface IRules<E> extends Rules<E> {
|
|
109
|
-
}
|
|
110
|
-
}
|
|
111
|
-
}
|
|
112
|
-
type LazyRules = n4s.IRules<LazyRuleMethods>;
|
|
113
|
-
type Lazy = LazyRules & LazyRuleMethods &
|
|
114
|
-
// This is a "catch all" hack to make TS happy while not
|
|
115
|
-
// losing type hints
|
|
116
|
-
Record<string, CB>;
|
|
117
|
-
type LazyRuleMethods = LazyRuleRunners & {
|
|
118
|
-
message: (message: LazyMessage) => Lazy;
|
|
119
|
-
};
|
|
120
|
-
type LazyRuleRunners = {
|
|
121
|
-
test: (value: unknown) => boolean;
|
|
122
|
-
run: (value: unknown) => RuleDetailedResult;
|
|
123
|
-
};
|
|
124
|
-
type LazyMessage = string | ((value: unknown, originalMessage?: Stringable) => string);
|
|
125
|
-
declare function isArrayOf(inputArray: any[], currentRule: LazyRuleRunners): RuleDetailedResult;
|
|
126
|
-
interface ShapeObject extends Record<string, any>, Record<string, LazyRuleRunners> {
|
|
127
|
-
}
|
|
128
|
-
declare function loose(inputObject: Record<string, any>, shapeObject: ShapeObject): RuleDetailedResult;
|
|
129
|
-
declare function optional(value: any, ruleChain: Lazy): RuleDetailedResult;
|
|
130
|
-
declare function shape(inputObject: Record<string, any>, shapeObject: ShapeObject): RuleDetailedResult;
|
|
131
|
-
// Help needed improving the typings of this file.
|
|
132
|
-
// Ideally, we'd be able to extend ShapeObject, but that's not possible.
|
|
133
|
-
declare function partial<T extends Record<any, any>>(shapeObject: T): T;
|
|
134
|
-
declare global {
|
|
135
|
-
namespace n4s {
|
|
136
|
-
interface EnforceCustomMatchers<R> {
|
|
137
|
-
isArrayOf: EnforceCustomMatcher<typeof isArrayOf, R>;
|
|
138
|
-
loose: EnforceCustomMatcher<typeof loose, R>;
|
|
139
|
-
shape: EnforceCustomMatcher<typeof shape, R>;
|
|
140
|
-
optional: EnforceCustomMatcher<typeof optional, R>;
|
|
141
|
-
}
|
|
142
|
-
}
|
|
143
|
-
}
|
|
144
|
-
export { partial };
|