ivl 0.1.4 → 0.1.5
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/lib/helpers/index.d.ts +2 -0
- package/lib/helpers/index.js +1 -1
- package/lib/index.d.ts +2 -2
- package/lib/index.js +1 -1
- package/package.json +55 -50
package/lib/helpers/index.d.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
// Generated by dts-bundle-generator v8.1.1
|
|
2
2
|
|
|
3
3
|
export type RULE = (value: unknown, ...overload: unknown[]) => boolean | Promise<boolean>;
|
|
4
|
+
export type RULE_SYNC = (value: unknown, ...overload: unknown[]) => boolean;
|
|
4
5
|
export type RULES = {
|
|
5
6
|
[index: string]: RULE;
|
|
6
7
|
};
|
|
@@ -9,6 +10,7 @@ export declare const matchesRegex: (regex: RegExp) => (value: unknown) => boolea
|
|
|
9
10
|
export declare const stringBetween: (max?: number, min?: number) => (s: unknown) => boolean;
|
|
10
11
|
export declare const numberBetween: (max?: number, min?: number) => (i: unknown) => boolean;
|
|
11
12
|
export declare const acceptAny: (rules?: RULE[]) => (i: unknown, ...extra: unknown[]) => Promise<boolean>;
|
|
13
|
+
export declare const acceptAnySync: (rules?: RULE_SYNC[]) => (i: unknown, ...extra: unknown[]) => boolean;
|
|
12
14
|
export declare const allowUndefined: (rules: RULES) => {};
|
|
13
15
|
export declare const preprocess: (fn: Function, rules: RULES) => {};
|
|
14
16
|
|
package/lib/helpers/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
var u=(e)=>(n)=>typeof n===e,
|
|
1
|
+
var u=(e)=>(n)=>typeof n===e,p=(e)=>(n)=>typeof n==="string"&&e.test(n),i=(e=100,n=0)=>(o)=>typeof o==="string"&&o.length>=n&&o.length<e,f=(e=100,n=1)=>(o)=>typeof o==="number"&&o>=n&&o<e,w=(e=[])=>async(n,...o)=>(await Promise.all(e.map((t)=>t.call(void 0,n,...o)))).some((t)=>t),a=(e=[])=>(n,...o)=>e.map((t)=>t.call(void 0,n,...o)).some((t)=>t);var l=(e)=>Object.entries(e).reduce((n,[o,t])=>({...n,[o]:(c,...r)=>typeof c==="undefined"?!0:t(c,...r)}),{}),d=(e,n)=>Object.entries(n).reduce((o,[t,c])=>({...o,[t]:(r,...s)=>c(e(r),...s)}),{});export{u as type,i as stringBetween,d as preprocess,f as numberBetween,p as matchesRegex,l as allowUndefined,a as acceptAnySync,w as acceptAny};
|
package/lib/index.d.ts
CHANGED
|
@@ -24,8 +24,8 @@ export type CHECKED_SCHEMA_SYNC = {
|
|
|
24
24
|
[index: string]: string[];
|
|
25
25
|
};
|
|
26
26
|
export declare const getValueErrors: (value: unknown, rules: RULES, ...overload: unknown[]) => Promise<string[]>;
|
|
27
|
-
export declare const getSchemaErrors: (object: CHECKABLE_OBJECT, schema: SCHEMA, strict?:
|
|
27
|
+
export declare const getSchemaErrors: (object: CHECKABLE_OBJECT, schema: SCHEMA, strict?: boolean, ...overload: unknown[]) => CHECKED_SCHEMA;
|
|
28
28
|
export declare const getValueErrorsSync: (value: unknown, rules: RULES_SYNC, ...overload: unknown[]) => string[];
|
|
29
|
-
export declare const getSchemaErrorsSync: (object: CHECKABLE_OBJECT, schema: SCHEMA_SYNC, strict?:
|
|
29
|
+
export declare const getSchemaErrorsSync: (object: CHECKABLE_OBJECT, schema: SCHEMA_SYNC, strict?: boolean, ...overload: unknown[]) => CHECKED_SCHEMA_SYNC;
|
|
30
30
|
|
|
31
31
|
export {};
|
package/lib/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
var U=async(E,S,...L)=>{const p={};return Object.entries(S).forEach(([n,x])=>{p[n]=Promise.resolve().then(()=>x(E,...L)).then((C)=>p[n]=C).catch(()=>{p[n]=!1})}),await Promise.allSettled(Object.values(p)),Object.entries(p).reduce((n,[x,C])=>C?n:[...n,x],[])},N=async(E,S,L=!1,...p)=>{const n={};if(Object.entries(S).forEach(([x,C])=>{n[x]=U(E[x],C,...p).then((i)=>{n[x]=i}).catch((i)=>{n[x]=i})}),L){const x=Object.keys(E),C=new Set(Object.keys(S));x.filter((R)=>!C.has(R)).forEach((R)=>{n[R]=["Key not allowed"]})}return await Promise.allSettled(Object.values(n)),n},H=(E,S,...L)=>Object.entries(S).reduce((p,[n,x])=>x(E,...L)?p:[...p,n],[]),Y=(E,S,L=!1,...p)=>{const n=Object.entries(S).reduce((x,[C,i])=>({...x,[C]:H(E[C],i,...p)}),{});if(L){const x=Object.keys(E),C=new Set(Object.keys(S));x.filter((R)=>!C.has(R)).forEach((R)=>{n[R]=["Key not allowed"]})}return n};export{H as getValueErrorsSync,U as getValueErrors,Y as getSchemaErrorsSync,N as getSchemaErrors};
|
|
1
|
+
var U=async(E,S,...L)=>{const p={};return Object.entries(S).forEach(([n,x])=>{p[n]=Promise.resolve().then(()=>x(E,...L)).then((C)=>p[n]=C).catch(()=>{p[n]=!1})}),await Promise.allSettled(Object.values(p)),Object.entries(p).reduce((n,[x,C])=>C?n:[...n,x],[])},N=async(E,S,L=!1,...p)=>{const n={};if(Object.entries(S).forEach(([x,C])=>{n[x]=U(E[x],C,...p).then((i)=>{n[x]=i}).catch((i)=>{n[x]=i})}),L){const x=Object.keys(E),C=new Set(Object.keys(S));x.filter((R)=>!C.has(R)).forEach((R)=>{n[R]=["Key not allowed"]})}return await Promise.allSettled(Object.values(n)),n},H=(E,S,...L)=>Object.entries(S).reduce((p,[n,x])=>{try{return x(E,...L)?p:[...p,n]}catch(C){return[...p,n]}},[]),Y=(E,S,L=!1,...p)=>{const n=Object.entries(S).reduce((x,[C,i])=>({...x,[C]:H(E[C],i,...p)}),{});if(L){const x=Object.keys(E),C=new Set(Object.keys(S));x.filter((R)=>!C.has(R)).forEach((R)=>{n[R]=["Key not allowed"]})}return n};export{H as getValueErrorsSync,U as getValueErrors,Y as getSchemaErrorsSync,N as getSchemaErrors};
|
package/package.json
CHANGED
|
@@ -1,52 +1,57 @@
|
|
|
1
1
|
{
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
2
|
+
"name": "ivl",
|
|
3
|
+
"version": "0.1.5",
|
|
4
|
+
"author": {
|
|
5
|
+
"name": "Oskar Voorel",
|
|
6
|
+
"email": "oskar@voorel.com"
|
|
7
|
+
},
|
|
8
|
+
"repository": {
|
|
9
|
+
"type": "git",
|
|
10
|
+
"url": "git+https://github.com/Oskar-V/validator.git"
|
|
11
|
+
},
|
|
12
|
+
"main": "lib/index.js",
|
|
13
|
+
"devDependencies": {
|
|
14
|
+
"@types/bun": "^1.0.0",
|
|
15
|
+
"bun-plugin-dts": "^0.2.1",
|
|
16
|
+
"mitata": "^0.1.11",
|
|
17
|
+
"typescript": "^5.2.2",
|
|
18
|
+
"yup": "^1.4.0",
|
|
19
|
+
"zod": "^3.23.8"
|
|
20
|
+
},
|
|
21
|
+
"exports": {
|
|
22
|
+
".": {
|
|
23
|
+
"types": "./lib/index.d.ts",
|
|
24
|
+
"default": "./lib/index.js"
|
|
25
|
+
},
|
|
26
|
+
"./patterns": {
|
|
27
|
+
"types": "./lib/patterns/index.d.ts",
|
|
28
|
+
"default": "./lib/patterns/index.js"
|
|
29
|
+
},
|
|
30
|
+
"./helpers": {
|
|
31
|
+
"types": "./lib/helpers/index.d.ts",
|
|
32
|
+
"default": "./lib/helpers/index.js"
|
|
33
|
+
}
|
|
34
|
+
},
|
|
35
|
+
"bugs": {
|
|
36
|
+
"url": "https://github.com/Oskar-V/validator/issues/new"
|
|
37
|
+
},
|
|
38
|
+
"description": "Lightweight input validation",
|
|
39
|
+
"files": [
|
|
40
|
+
"lib"
|
|
41
|
+
],
|
|
42
|
+
"homepage": "https://github.com/Oskar-V/validator",
|
|
43
|
+
"keywords": [
|
|
44
|
+
"validation",
|
|
45
|
+
"typescript",
|
|
46
|
+
"schema",
|
|
47
|
+
"input"
|
|
48
|
+
],
|
|
49
|
+
"license": "MIT",
|
|
50
|
+
"scripts": {
|
|
51
|
+
"build": "bun run build.mjs",
|
|
52
|
+
"prepublishOnly": "bun run build",
|
|
53
|
+
"benchmark": "bun run ./benchmark/index.ts"
|
|
54
|
+
},
|
|
55
|
+
"sideEffects": "false",
|
|
56
|
+
"types": "lib/index.d.ts"
|
|
52
57
|
}
|