ivl 0.1.5 → 0.2.0

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/README.md CHANGED
@@ -2,51 +2,76 @@
2
2
  This is a lightweight library for user input validation.
3
3
  Main focus is on speed and flexibility of the validation rules
4
4
 
5
- Supports asynchronous rule validation by default. Use `getInputErrorsSync` and `getSchemaErrorsSync` for better performance if you don't need to support asynchronous checks on your inputs.
5
+ By default it automatically detects and supports async rules in your rule sets.
6
+
7
+ If your rule set and/or object are very large or complex, you may want to use
8
+ `getInputErrorsSync`/`getSchemaErrorsSync` or `getInputErrorsAsync`/`getSchemaErrorsAsync` for improved performance on synchronous and asynchronous rule sets respectively.
9
+
10
+ Use synchronous versions of the functions for better performance if you don't need to support asynchronous checks on your inputs.
11
+
12
+
6
13
  # Main functionality
7
- Write your own custom validators to exactly match your usecase using a simple object:
14
+ Write your own custom validators to exactly match your use case using a simple object:
8
15
  ```javascript
9
16
  const my_rules = {
10
- "Input must be more than 4": (i) => i > 4,
11
- "Input must be divisible by 10": (i) => i % 10
17
+ "Input must be more than 40": (i) => i > 40,
18
+ "Input must be divisible by 10": (i) => !(i % 10)
12
19
  }
20
+ console.log(getInputErrors(50, my_rules)); // []
21
+ console.log(getInputErrors(11, my_rules)); // ["Input must be more than 40", "Input must be divisible by 10"]
22
+ console.log(getInputErrors(30, my_rules)) // ["Input must be more than 40"]
23
+
24
+ ```
25
+ # Installing
26
+ ### Bun.js
27
+ ```typescript
28
+ bun add ivl
13
29
  ```
14
- The input will be checked against your rule set and return all failing rules names as a string array.
15
30
 
31
+ ### yarn
32
+ ```typescript
33
+ yarn add ivl
34
+ ```
16
35
 
36
+ ### npm
37
+ ```typescript
38
+ npm install ivl
39
+ ```
40
+ ---
41
+ # Usage examples
17
42
  ## Frontend example
18
43
  ```javascript
19
44
  // src/index.ts
20
45
  import { getInputErrorsSync, getInputErrors } from 'ivl';
21
46
  import type { RULES } from 'ivl';
22
- import { matchesRegex, stringBetween, type } from 'ivl/helpers';
47
+ import { matchesRegex, minLength, maxLength, isType } from 'ivl/helpers';
23
48
 
24
- // This is also exportable from 'ivl/patterns'
49
+ // This pattern is also exportable from 'ivl/patterns'
25
50
  const EMAIL_PATTERN = /^[\w.%+-]+@[\w.-]+\.[a-zA-Z]{1,}$/;
26
51
 
27
52
  const EMAIL_REQUIREMENTS: RULES = {
28
- "Must be string": type('string'),
29
- "Must be less then 100 characters": stringBetween(),
30
- "Not a valid email address": matchesRegex(EMAIL_PATTERN),
31
- "That email is already in use": async (i) => {
32
- // Fetch info from whatever backend and make a decision based on that asynchronously
33
- const email_in_use = await fetch(`https://mybackend/email-exists/${i}`)
34
- return !email_in_use // We will return true if the email is not already taken
35
- }
53
+ "Must be string": isType('string'),
54
+ "Must be less then 100 characters": maxLength(100),
55
+ "Not a valid email address": matchesRegex(EMAIL_PATTERN),
56
+ "That email is already in use": async (i) => {
57
+ // Fetch info from whatever backend and make a decision based on that asynchronously
58
+ const email_in_use = await fetch(`https://mybackend/email-exists/${i}`)
59
+ return !email_in_use // We will return true if the email is not already taken
60
+ }
36
61
  };
37
62
 
38
63
  const PASSWORD_REQUIREMENTS: RULES = {
39
- "Must be string": type('string'),
40
- "Must be at least 8 characters": stringBetween(Infinity, 8),
41
- "Must contain at least one upper case character": matchesRegex(/(?=.*[A-Z])/),
42
- "Must contain at least one lower case character": matchesRegex(/(?=.*[a-z])/),
43
- }
64
+ "Must be string": isType('string'),
65
+ "Must be at least 8 characters": minLength(8),
66
+ "Must contain at least one upper case character": matchesRegex(/(?=.*[A-Z])/),
67
+ "Must contain at least one lower case character": matchesRegex(/(?=.*[a-z])/),
68
+ };
44
69
 
45
70
  // You can of course expand on your existing rules:
46
71
  const STRONG_PASSWORD_REQUIREMENTS: RULES = {
47
- ...PASSWORD_REQUIREMENTS,
48
- "Must contain at least one digit": matchesRegex(/(?=.*\d)/),
49
- "Must contain at least one symbol": matchesRegex(/[^\w]/),
72
+ ...PASSWORD_REQUIREMENTS,
73
+ "Must contain at least one digit": matchesRegex(/(?=.*\d)/),
74
+ "Must contain at least one symbol": matchesRegex(/[^\w]/),
50
75
  };
51
76
 
52
77
  const email_value = "some-value";
@@ -64,40 +89,48 @@ console.log({email_errors, pw_errors, strong_pw_errors});
64
89
 
65
90
  ```typescript
66
91
  // rules.ts
92
+
93
+ import { isType, minLength, maxLength, matchesRegex } from 'ivl/helpers';
94
+ import { checkValueInDatabase } from 'my-database-controller';
95
+
96
+ const existsInDatabase = (key: string, table: string, exists: boolean = true): RULE =>
97
+ async (value) =>
98
+ exists != !(await checkValueInDatabase(value as string, key, table)).length
99
+
67
100
  const EMAIL_REQUIREMENTS = {
68
- "Must be string": type('string'),
69
- "Must be less then 100 characters": stringBetween(),
70
- "Not a valid email address": matchesRegex(EMAIL_PATTERN),
101
+ "Must be string": isType('string'),
102
+ "Must be less then 100 characters": maxLength(100),
103
+ "Not a valid email address": matchesRegex(EMAIL_PATTERN),
71
104
  };
72
105
 
73
106
  const PASSWORD_REQUIREMENTS = {
74
- "Must be string": type('string'),
75
- "Must be at least 8 characters": stringBetween(Infinity, 8),
76
- "Must contain at least one upper case character": matchesRegex(/(?=.*[A-Z])/),
77
- "Must contain at least one lower case character": matchesRegex(/(?=.*[a-z])/),
78
- "Must contain at least one digit": matchesRegex(/(?=.*\d)/),
79
- "Must contain at least one symbol": matchesRegex(/[^\w]/),
107
+ "Must be string": isType('string'),
108
+ "Must be at least 8 characters": minLength(8),
109
+ "Must contain at least one upper case character": matchesRegex(/(?=.*[A-Z])/),
110
+ "Must contain at least one lower case character": matchesRegex(/(?=.*[a-z])/),
111
+ "Must contain at least one digit": matchesRegex(/(?=.*\d)/),
112
+ "Must contain at least one symbol": matchesRegex(/[^\w]/),
80
113
  };
81
114
 
82
- export const LOGIN_SCHEMA = {
83
- email: EMAIL_REQUIREMENTS,
84
- password: PASSWORD_REQUIREMENTS
85
- }
115
+ export const LOGIN_SCHEMA: SCHEMA = {
116
+ email: EMAIL_REQUIREMENTS,
117
+ password: PASSWORD_REQUIREMENTS
118
+ };
86
119
 
87
- export const REGISTER_SCHEMA = {
88
- organization_name: {} // Pass in an empty rule set, so the value can be whatever
89
- email: {
90
- ...EMAIL_REQUIREMENTS,
91
- "Email already registered": checkValueInDatabase('email','users', false)
92
- },
93
- password: PASSWORD_REQUIREMENTS
94
- }
120
+ export const REGISTER_SCHEMA: SCHEMA = {
121
+ organization_name: {} // Pass in an empty rule set, so the value can be whatever
122
+ email: {
123
+ ...EMAIL_REQUIREMENTS,
124
+ "Email already registered": existsInDatabase('email','users', false)
125
+ },
126
+ password: PASSWORD_REQUIREMENTS
127
+ };
95
128
 
96
129
  export const INVITATION_PARAM: SCHEMA = {
97
- code: {
98
- "Not a valid invitation": existsInDatabase('code', 'invitation')
99
- }
100
- }
130
+ code: {
131
+ "Not a valid invitation": existsInDatabase('code', 'invitation')
132
+ }
133
+ };
101
134
 
102
135
  ```
103
136
 
@@ -108,47 +141,47 @@ import { jwt } from 'hono/jwt';
108
141
  import { validator } from 'hono/validator';
109
142
  import { getSchemaErrors } from 'ivl';
110
143
  import type { SCHEMA } from 'ivl';
111
- import { LOGIN_SCHEMA, REGISTER_SCHEMA, INVITATION_PARAM } from './rules.ts'
144
+ import { LOGIN_SCHEMA, REGISTER_SCHEMA, INVITATION_PARAM } from './rules.ts';
112
145
 
113
146
  // Wrapper for hono validator middleware
114
147
  const validateWrapper = (schema: SCHEMA, error: ClientErrorStatusCode | RedirectStatusCode = 400, strict = true) =>
115
- async (value: any, c: Context) => {
116
- const jwt = c.get('jwtPayload'); // Pass jwt to the validator so we could use its value when checking input validation rules
117
- const errors = await getSchemaErrors(value, schema, strict, jwt);
118
- if (Object.values(errors).filter((e) => e.length).length) {
119
- throw new HTTPException(error, {
120
- message: JSON.stringify(errors),
121
- })
122
- }
123
- return value
124
- }
148
+ async (value: any, c: Context) => {
149
+ const jwt = c.get('jwtPayload'); // Pass jwt to the validator so we could use its value when checking input validation rules
150
+ const errors = await getSchemaErrors(value, schema, {strict:true}, jwt);
151
+ if (Object.values(errors).filter((e) => e.length).length) {
152
+ throw new HTTPException(error, {
153
+ message: JSON.stringify(errors),
154
+ });
155
+ }
156
+ return value;
157
+ }
125
158
 
126
159
  const app = new Hono();
127
160
 
128
161
  app.use(jwt({
129
- secret: "some-secret-value",
130
- cookie: 'token'
131
- }))
162
+ secret: "some-secret-value",
163
+ cookie: 'token'
164
+ }));
132
165
 
133
166
  app.post('/login',
134
- validator('json', validateWrapper(LOGIN_SCHEMA)),
135
- (c) => c.text("Success"));
167
+ validator('json', validateWrapper(LOGIN_SCHEMA)),
168
+ (c) => c.text("Success"));
136
169
 
137
170
  app.all('/logout', (c) => c.text("Success"));
138
171
 
139
172
  app.put('/register',
140
- validator('json', validateWrapper(REGISTER_SCHEMA)),
141
- (c) => c.text("Success"));
173
+ validator('json', validateWrapper(REGISTER_SCHEMA)),
174
+ (c) => c.text("Success"));
142
175
 
143
176
  // This first validates the invitation parameter against our database
144
177
  // And then validates the body of the request
145
178
  app.put('/register/:invitation_code',
146
- validator('param', validateWrapper(INVITATION_PARAM)),
147
- validator('json', validateWrapper(
148
- // Registering via invitation needs all the same values except organization name - inherit parts of rule sets, as opposed to extending the rule set as shown above
149
- (({ organization_name, ...invite_schema }) => invite_schema)(REGISTRATION_SCHEMA)
150
- )),
151
- (c)=> c.text("Success")))
179
+ validator('param', validateWrapper(INVITATION_PARAM)),
180
+ validator('json', validateWrapper(
181
+ // Registering via invitation needs all the same values except organization name - inherit parts of rule sets, as opposed to extending the rule set as shown above
182
+ (({ organization_name, ...invite_schema }) => invite_schema)(REGISTRATION_SCHEMA)
183
+ )),
184
+ (c)=> c.text("Success"));
152
185
 
153
186
  export default app;
154
187
  ```
@@ -1,16 +1,20 @@
1
1
  // Generated by dts-bundle-generator v8.1.1
2
2
 
3
- export type RULE = (value: unknown, ...overload: unknown[]) => boolean | Promise<boolean>;
4
3
  export type RULE_SYNC = (value: unknown, ...overload: unknown[]) => boolean;
4
+ export type RULE = (value: unknown, ...overload: unknown[]) => boolean | Promise<boolean>;
5
5
  export type RULES = {
6
6
  [index: string]: RULE;
7
7
  };
8
- export declare const type: (type: "string" | "number" | "bigint" | "boolean" | "symbol" | "undefined" | "object" | "function") => RULE;
9
- export declare const matchesRegex: (regex: RegExp) => (value: unknown) => boolean;
10
- export declare const stringBetween: (max?: number, min?: number) => (s: unknown) => boolean;
11
- export declare const numberBetween: (max?: number, min?: number) => (i: unknown) => boolean;
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;
8
+ export declare const isType: (type: "string" | "number" | "bigint" | "boolean" | "symbol" | "undefined" | "object" | "function") => RULE_SYNC;
9
+ export declare const matchesRegex: (regex: RegExp) => RULE_SYNC;
10
+ export declare const max: (max_value?: number) => RULE_SYNC;
11
+ export declare const min: (min_value?: number) => RULE_SYNC;
12
+ export declare const maxLength: (max_length?: number) => RULE_SYNC;
13
+ export declare const minLength: (min_length?: number) => RULE_SYNC;
14
+ export declare const stringBetween: (max?: number, min?: number) => RULE_SYNC;
15
+ export declare const numberBetween: (max?: number, min?: number) => RULE_SYNC;
16
+ export declare const acceptAny: (rules?: RULE[]) => RULE;
17
+ export declare const acceptAnySync: (rules?: RULE_SYNC[]) => RULE_SYNC;
14
18
  export declare const allowUndefined: (rules: RULES) => {};
15
19
  export declare const preprocess: (fn: Function, rules: RULES) => {};
16
20
 
@@ -1 +1 @@
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};
1
+ var s=(n)=>n!==null&&typeof n==="object"&&("length"in n)&&typeof n.length==="number",p=(n)=>(e)=>typeof e===n,i=(n)=>(e)=>typeof e==="string"&&n.test(e),m=(n=1/0)=>(e)=>typeof e==="number"&&e<=n,f=(n=-1/0)=>(e)=>typeof e==="number"&&e>=n,w=(n=1/0)=>(e)=>s(e)&&e.length<=n,y=(n=1/0)=>(e)=>s(e)&&e.length>=n,a=(n=100,e=0)=>(t)=>typeof t==="string"&&t.length>=e&&t.length<n,L=(n=100,e=1)=>(t)=>typeof t==="number"&&t>=e&&t<n,h=(n=[])=>async(e,...t)=>(await Promise.all(n.map((o)=>o(void 0,e,...t)))).some((o)=>o),R=(n=[])=>(e,...t)=>n.map((o)=>o(void 0,e,...t)).some((o)=>o);var g=(n)=>Object.entries(n).reduce((e,[t,o])=>({...e,[t]:(r,...u)=>typeof r==="undefined"?!0:o(r,...u)}),{}),l=(n,e)=>Object.entries(e).reduce((t,[o,r])=>({...t,[o]:(u,...c)=>r(n(u),...c)}),{});export{a as stringBetween,l as preprocess,L as numberBetween,y as minLength,f as min,w as maxLength,m as max,i as matchesRegex,p as isType,g as allowUndefined,R as acceptAnySync,h as acceptAny};
package/lib/index.d.ts CHANGED
@@ -1,31 +1,39 @@
1
1
  // Generated by dts-bundle-generator v8.1.1
2
2
 
3
- export type RULE = (value: unknown, ...overload: unknown[]) => boolean | Promise<boolean>;
4
3
  export type RULE_SYNC = (value: unknown, ...overload: unknown[]) => boolean;
5
- export type RULES = {
6
- [index: string]: RULE;
7
- };
4
+ export type RULE = (value: unknown, ...overload: unknown[]) => boolean | Promise<boolean>;
8
5
  export type RULES_SYNC = {
9
6
  [index: string]: RULE_SYNC;
10
7
  };
11
- export type SCHEMA = {
12
- [index: string]: RULES;
8
+ export type RULES = {
9
+ [index: string]: RULE;
13
10
  };
14
11
  export type SCHEMA_SYNC = {
15
12
  [index: string]: RULES_SYNC;
16
13
  };
14
+ export type SCHEMA = {
15
+ [index: string]: RULES;
16
+ };
17
17
  export type CHECKABLE_OBJECT = {
18
18
  [index: string]: unknown;
19
19
  };
20
- export type CHECKED_SCHEMA = Promise<{
21
- [index: string]: string[];
22
- }>;
20
+ /**
21
+ * @arg {boolean} strict --- Don't allow object to have keys not included in the schema
22
+ * @arg {boolean} break_early --- Return the first error found
23
+ */
24
+ export type SCHEMA_OPTIONS = {
25
+ strict?: boolean;
26
+ };
23
27
  export type CHECKED_SCHEMA_SYNC = {
24
28
  [index: string]: string[];
25
29
  };
26
- export declare const getValueErrors: (value: unknown, rules: RULES, ...overload: unknown[]) => Promise<string[]>;
27
- export declare const getSchemaErrors: (object: CHECKABLE_OBJECT, schema: SCHEMA, strict?: boolean, ...overload: unknown[]) => CHECKED_SCHEMA;
30
+ export type CHECKED_SCHEMA = Promise<CHECKED_SCHEMA_SYNC>;
31
+ export declare const hasAsyncFunction: (obj: Record<string, unknown>) => boolean;
32
+ export declare const getValueErrorsAsync: (value: unknown, rules: RULES, ...overload: unknown[]) => Promise<string[]>;
33
+ export declare const getSchemaErrorsAsync: (object: CHECKABLE_OBJECT, schema: SCHEMA, options?: SCHEMA_OPTIONS, ...overload: unknown[]) => CHECKED_SCHEMA;
28
34
  export declare const getValueErrorsSync: (value: unknown, rules: RULES_SYNC, ...overload: unknown[]) => string[];
29
- export declare const getSchemaErrorsSync: (object: CHECKABLE_OBJECT, schema: SCHEMA_SYNC, strict?: boolean, ...overload: unknown[]) => CHECKED_SCHEMA_SYNC;
35
+ export declare const getSchemaErrorsSync: (object: CHECKABLE_OBJECT, schema: SCHEMA_SYNC, options?: SCHEMA_OPTIONS, ...overload: unknown[]) => CHECKED_SCHEMA_SYNC;
36
+ export declare const getValueErrors: (value: unknown, rules: RULES | RULES_SYNC, ...overload: unknown[]) => string[] | Promise<string[]>;
37
+ export declare const getSchemaErrors: (object: CHECKABLE_OBJECT, schema: SCHEMA_SYNC | SCHEMA, options?: SCHEMA_OPTIONS, ...overload: unknown[]) => CHECKED_SCHEMA_SYNC | CHECKED_SCHEMA;
30
38
 
31
39
  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])=>{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};
1
+ var W={strict:!1},X=(q)=>Object.values(q).some((x)=>typeof x==="function"&&x.constructor.name==="AsyncFunction"),Y=async(q,x,...G)=>{const z={};return Object.entries(x).forEach(([f,B])=>{z[f]=Promise.resolve(!1).then(()=>B(q,...G)).then((J)=>z[f]=J).catch(()=>z[f]=!1)}),await Promise.allSettled(Object.values(z)),Object.entries(z).reduce((f,[B,J])=>J?f:[...f,B],[])},$=async(q,x,G=W,...z)=>{const f={};if(Object.entries(x).forEach(([B,J])=>{f[B]=Y(q[B],J,...z).then((K)=>{f[B]=K}).catch((K)=>{f[B]=K})}),G.strict){const B=Object.keys(q),J=new Set(Object.keys(x));B.filter((Q)=>!J.has(Q)).forEach((Q)=>{f[Q]=["Key not allowed"]})}return await Promise.allSettled(Object.values(f)),f},Z=(q,x,...G)=>Object.entries(x).reduce((z,[f,B])=>{try{return B(q,...G)?z:[...z,f]}catch(J){return[...z,f]}},[]),R=(q,x,G=W,...z)=>{const f=Object.entries(x).reduce((B,[J,K])=>({...B,[J]:Z(q[J],K,...z)}),{});if(G.strict){const B=Object.keys(q),J=new Set(Object.keys(x));B.filter((Q)=>!J.has(Q)).forEach((Q)=>{f[Q]=["Key not allowed"]})}return f},C=(q,x,...G)=>{if(X(x))return Y(q,x,...G);return Z(q,x,...G)},H=(q,x,G=W,...z)=>{if(Object.values(x).some(X))return $(q,x,G,...z);return R(q,x,G,...z)};export{X as hasAsyncFunction,Z as getValueErrorsSync,Y as getValueErrorsAsync,C as getValueErrors,R as getSchemaErrorsSync,$ as getSchemaErrorsAsync,H as getSchemaErrors};
@@ -1,7 +1,15 @@
1
1
  // Generated by dts-bundle-generator v8.1.1
2
2
 
3
3
  export declare const EMAIL_PATTERN: RegExp;
4
- export declare const TIMESTAMP_PATTERN: RegExp;
4
+ export declare const MYSQL_TIMESTAMP_PATTERN: RegExp;
5
5
  export declare const URL_PATTERN: RegExp;
6
+ export declare const ISO_8601_DATETIME_PATTERN_STRICT: RegExp;
7
+ export declare const ISO_8601_DATETIME_PATTERN: RegExp;
8
+ export declare const ISO_8601_TIME_PATTERN: RegExp;
9
+ export declare const RFC_2822_TIMESTAMP_PATTERN: RegExp;
10
+ export declare const CONTAINS_LOWERCASE_CHARACTER_PATTERN: RegExp;
11
+ export declare const CONTAINS_UPPERCASE_CHARACTER_PATTERN: RegExp;
12
+ export declare const CONTAINS_DIGIT_CHARACTER_PATTERN: RegExp;
13
+ export declare const CONTAINS_SYMBOL_CHARACTER_PATTERN: RegExp;
6
14
 
7
15
  export {};
@@ -1 +1 @@
1
- var T=/^[\w.%+-]+@[\w.-]+\.[a-zA-Z]{1,}$/,s=/^(\d{4})-(\d{2})-(\d{2}) (\d{2}):(\d{2}):(\d{2})$/,t=/^(https?:\/\/)?([^\s$.?#].[^\s]*)\.[a-z]{2,}(\/[^\s]*)?$/i;export{t as URL_PATTERN,s as TIMESTAMP_PATTERN,T as EMAIL_PATTERN};
1
+ var x=/^[\w.%+-]+@[\w.-]+\.[a-zA-Z]{1,}$/,c=/^(\d{4})-(\d{2})-(\d{2}) (\d{2}):(\d{2}):(\d{2})$/,d=/^(https?:\/\/)?([^\s$.?#].[^\s]*)\.[a-z]{2,}(\/[^\s]*)?$/i,f=/^(\d{4}-[01]\d-[0-3]\dT[0-2]\d:[0-5]\d:[0-5]\d\.\d+([+-][0-2]\d:[0-5]\d|Z))|(\d{4}-[01]\d-[0-3]\dT[0-2]\d:[0-5]\d:[0-5]\d([+-][0-2]\d:[0-5]\d|Z))|(\d{4}-[01]\d-[0-3]\dT[0-2]\d:[0-5]\d([+-][0-2]\d:[0-5]\d|Z))$/,j=/^(\d{4}-[01]\d-[0-3]\dT[0-2]\d:[0-5]\d:[0-5]\d\.\d+)|(\d{4}-[01]\d-[0-3]\dT[0-2]\d:[0-5]\d:[0-5]\d)|(\d{4}-[01]\d-[0-3]\dT[0-2]\d:[0-5]\d)$/,k=/^(2[0-3]|[01][0-9]):?([0-5][0-9]):?([0-5][0-9])(Z|[+-](?:2[0-3]|[01][0-9])(?::?(?:[0-5][0-9]))?)$/,l=/^(?:(Sun|Mon|Tue|Wed|Thu|Fri|Sat),\s+)?(0[1-9]|[1-2]?[0-9]|3[01])\s+(Jan|Feb|Mar|Apr|May|Jun|Jul|Aug|Sep|Oct|Nov|Dec)\s+(19[0-9]{2}|[2-9][0-9]{3})\s+(2[0-3]|[0-1][0-9]):([0-5][0-9])(?::(60|[0-5][0-9]))?\s+([-\+][0-9]{2}[0-5][0-9]|(?:UT|GMT|(?:E|C|M|P)(?:ST|DT)|[A-IK-Z]))(\s+|\(([^\(\)]+|\\\(|\\\))*\))*$/,m=/(?=.*[a-z])/,p=/(?=.*[A-Z])/,q=/(?=.*\d)/,r=/[^\w]/;export{d as URL_PATTERN,l as RFC_2822_TIMESTAMP_PATTERN,c as MYSQL_TIMESTAMP_PATTERN,k as ISO_8601_TIME_PATTERN,f as ISO_8601_DATETIME_PATTERN_STRICT,j as ISO_8601_DATETIME_PATTERN,x as EMAIL_PATTERN,p as CONTAINS_UPPERCASE_CHARACTER_PATTERN,r as CONTAINS_SYMBOL_CHARACTER_PATTERN,m as CONTAINS_LOWERCASE_CHARACTER_PATTERN,q as CONTAINS_DIGIT_CHARACTER_PATTERN};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ivl",
3
- "version": "0.1.5",
3
+ "version": "0.2.0",
4
4
  "author": {
5
5
  "name": "Oskar Voorel",
6
6
  "email": "oskar@voorel.com"
@@ -11,7 +11,7 @@
11
11
  },
12
12
  "main": "lib/index.js",
13
13
  "devDependencies": {
14
- "@types/bun": "^1.0.0",
14
+ "@types/bun": "latest",
15
15
  "bun-plugin-dts": "^0.2.1",
16
16
  "mitata": "^0.1.11",
17
17
  "typescript": "^5.2.2",
@@ -48,7 +48,7 @@
48
48
  ],
49
49
  "license": "MIT",
50
50
  "scripts": {
51
- "build": "bun run build.mjs",
51
+ "build": "rm -rf ./lib && bun run build.mjs",
52
52
  "prepublishOnly": "bun run build",
53
53
  "benchmark": "bun run ./benchmark/index.ts"
54
54
  },