ivl 0.1.0 → 0.1.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.
- package/lib/index.d.ts +12 -0
- package/lib/index.js +1 -1
- package/package.json +1 -1
package/lib/index.d.ts
CHANGED
|
@@ -13,5 +13,17 @@ export type SCHEMA = {
|
|
|
13
13
|
export type CHECKED_SCHEMA = Promise<{
|
|
14
14
|
[index: string]: string[];
|
|
15
15
|
}>;
|
|
16
|
+
export declare const getValueErrors: (value: unknown, rules: RULES, ...overload: unknown[]) => Promise<string[]>;
|
|
17
|
+
export declare const getSchemaErrors: (object: CHECKABLE_OBJECT, schema: SCHEMA, strict?: Boolean, ...overload: unknown[]) => CHECKED_SCHEMA;
|
|
18
|
+
export declare const type: (type: "string" | "number" | "bigint" | "boolean" | "symbol" | "undefined" | "object" | "function") => RULE;
|
|
19
|
+
export declare const matchesRegex: (regex: RegExp) => RULE;
|
|
20
|
+
export declare const stringBetween: (max?: number, min?: number) => (s: unknown) => boolean;
|
|
21
|
+
export declare const numberBetween: (max?: number, min?: number) => (i: unknown) => boolean;
|
|
22
|
+
export declare const acceptAny: (rules?: RULE[]) => (i: unknown, ...extra: unknown[]) => Promise<boolean>;
|
|
23
|
+
export declare const allowUndefined: (rules: RULES) => {};
|
|
24
|
+
export declare const preprocess: (fn: Function, rules: RULES) => {};
|
|
25
|
+
export declare const EMAIL_PATTERN: RegExp;
|
|
26
|
+
export declare const TIMESTAMP_PATTERN: RegExp;
|
|
27
|
+
export declare const URL_PATTERN: RegExp;
|
|
16
28
|
|
|
17
29
|
export {};
|
package/lib/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
var
|
|
1
|
+
var L=Object.defineProperty;var U=(o,n)=>{for(var t in n)L(o,t,{get:n[t],enumerable:!0,configurable:!0,set:(E)=>n[t]=()=>E})};var f={};U(f,{getValueErrors:()=>w,getSchemaErrors:()=>C});var w=async(o,n,...t)=>{const E={};return Object.entries(n).forEach(([p,i])=>{E[p]=Promise.resolve().then(()=>i(o,...t)).then((x)=>E[p]=x).catch(()=>{E[p]=!1})}),await Promise.allSettled(Object.values(E)),Object.entries(E).reduce((p,[i,x])=>x?p:[...p,i],[])},C=async(o,n,t=!1,...E)=>{const p={};if(Object.entries(n).forEach(([i,x])=>{p[i]=w(o[i],x,...E).then((R)=>{p[i]=R}).catch((R)=>{p[i]=R})}),t){const i=Object.keys(o),x=new Set(Object.keys(n));i.filter((d)=>!x.has(d)).forEach((d)=>{p[d]=["Key not allowed"]})}return await Promise.allSettled(Object.values(p)),p};var e=(o)=>(n)=>typeof n===o,m=(o)=>(n)=>typeof n==="string"&&o.test(n),g=(o=100,n=0)=>(t)=>typeof t==="string"&&t.length>=n&&t.length<o,S=(o=100,n=1)=>(t)=>typeof t==="number"&&t>=n&&t<o,T=(o=[])=>async(n,...t)=>(await Promise.all(o.map((E)=>E.call(void 0,n,...t)))).some((E)=>E),u=(o)=>Object.entries(o).reduce((n,[t,E])=>({...n,[t]:(p,...i)=>typeof p==="undefined"?!0:E(p,...i)}),{}),H=(o,n)=>Object.entries(n).reduce((t,[E,p])=>({...t,[E]:(i,...x)=>p(o(i),...x)}),{});var M=/^[\w.%+-]+@[\w.-]+\.[a-zA-Z]{1,}$/,P=/^(\d{4})-(\d{2})-(\d{2}) (\d{2}):(\d{2}):(\d{2})$/,B=/^(https?:\/\/)?([^\s$.?#].[^\s]*)\.[a-z]{2,}(\/[^\s]*)?$/i;var K=f;export{e as type,g as stringBetween,H as preprocess,S as numberBetween,m as matchesRegex,f as ivl,w as getValueErrors,C as getSchemaErrors,K as default,u as allowUndefined,T as acceptAny,B as URL_PATTERN,P as TIMESTAMP_PATTERN,M as EMAIL_PATTERN};
|