@hedystia/validations 1.6.9 → 1.7.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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@hedystia/validations",
3
- "version": "1.6.9",
3
+ "version": "1.7.0",
4
4
  "devDependencies": {
5
5
  "@standard-schema/spec": "^1.0.0",
6
6
  "@types/bun": "latest",
@@ -17,8 +17,8 @@
17
17
  "private": false,
18
18
  "license": "MIT",
19
19
  "scripts": {
20
- "build": "tsup",
21
- "dev": "bun --watch --no-clear-screen run src/index.ts"
20
+ "build": "cargo clean && wasm-pack build --target nodejs && tsup && cp pkg/validations_bg.wasm dist/",
21
+ "dev": "bun --watch --no-clear-screen run index.ts"
22
22
  },
23
23
  "repository": {
24
24
  "type": "git",
package/dist/index.d.ts DELETED
@@ -1,302 +0,0 @@
1
- /** The Standard Schema interface. */
2
- interface StandardSchemaV1<Input = unknown, Output = Input> {
3
- /** The Standard Schema properties. */
4
- readonly "~standard": StandardSchemaV1.Props<Input, Output>;
5
- }
6
- declare namespace StandardSchemaV1 {
7
- /** The Standard Schema properties interface. */
8
- export interface Props<Input = unknown, Output = Input> {
9
- /** The version number of the standard. */
10
- readonly version: 1;
11
- /** The vendor name of the schema library. */
12
- readonly vendor: string;
13
- /** Validates unknown input values. */
14
- readonly validate: (value: unknown) => Result<Output> | Promise<Result<Output>>;
15
- /** Inferred types associated with the schema. */
16
- readonly types?: Types<Input, Output> | undefined;
17
- }
18
- /** The result interface of the validate function. */
19
- export type Result<Output> = SuccessResult<Output> | FailureResult;
20
- /** The result interface if validation succeeds. */
21
- export interface SuccessResult<Output> {
22
- /** The typed output value. */
23
- readonly value: Output;
24
- /** The non-existent issues. */
25
- readonly issues?: undefined;
26
- }
27
- /** The result interface if validation fails. */
28
- export interface FailureResult {
29
- /** The issues of failed validation. */
30
- readonly issues: ReadonlyArray<Issue>;
31
- }
32
- /** The issue interface of the failure output. */
33
- export interface Issue {
34
- /** The error message of the issue. */
35
- readonly message: string;
36
- /** The path of the issue, if any. */
37
- readonly path?: ReadonlyArray<PropertyKey | PathSegment> | undefined;
38
- }
39
- /** The path segment interface of the issue. */
40
- export interface PathSegment {
41
- /** The key representing a path segment. */
42
- readonly key: PropertyKey;
43
- }
44
- /** The Standard Schema types interface. */
45
- export interface Types<Input = unknown, Output = Input> {
46
- /** The input type of the schema. */
47
- readonly input: Input;
48
- /** The output type of the schema. */
49
- readonly output: Output;
50
- }
51
- /** Infers the input type of a Standard Schema. */
52
- export type InferInput<Schema extends StandardSchemaV1> = NonNullable<Schema["~standard"]["types"]>["input"];
53
- /** Infers the output type of a Standard Schema. */
54
- export type InferOutput<Schema extends StandardSchemaV1> = NonNullable<Schema["~standard"]["types"]>["output"];
55
- export { };
56
- }
57
-
58
- type SchemaPrimitive = "string" | "number" | "boolean" | "any";
59
- interface SchemaLike {
60
- [key: string]: SchemaPrimitive | SchemaLike | BaseSchema<any, any>;
61
- }
62
- type Simplify<T> = T extends any ? {
63
- [K in keyof T]: T[K];
64
- } : never;
65
- type RequiredKeys<S> = {
66
- [K in keyof S]: S[K] extends OptionalSchema<any, any> ? never : K;
67
- }[keyof S];
68
- type OptionalKeys<S> = {
69
- [K in keyof S]: S[K] extends OptionalSchema<any, any> ? K : never;
70
- }[keyof S];
71
- type SchemaPrimitiveMap = {
72
- string: string;
73
- number: number;
74
- boolean: boolean;
75
- any: unknown;
76
- };
77
- type SchemaType<S> = S extends BaseSchema<any, infer O> ? O : S extends keyof SchemaPrimitiveMap ? SchemaPrimitiveMap[S] : S extends Record<string, any> ? InferSchema<S> : unknown;
78
- type InferObject<S extends SchemaDefinition> = Simplify<{
79
- [K in RequiredKeys<S>]: SchemaType<S[K]>;
80
- } & {
81
- [K in OptionalKeys<S>]?: SchemaType<S[K]>;
82
- }>;
83
- type InferSchema<S> = S extends BaseSchema<any, infer O> ? O : S extends "string" ? string : S extends "number" ? number : S extends "boolean" ? boolean : S extends {
84
- [key: string]: any;
85
- } ? {
86
- [K in keyof S as undefined extends InferSchema<S[K]> ? K : never]?: InferSchema<S[K]>;
87
- } & {
88
- [K in keyof S as undefined extends InferSchema<S[K]> ? never : K]: InferSchema<S[K]>;
89
- } : unknown;
90
- type SchemaDefinition = SchemaLike;
91
- interface Schema<I, O> extends StandardSchemaV1<I, O> {
92
- optional(): OptionalSchema<I, O | undefined>;
93
- enum<V extends O & (string | number | boolean), Values extends readonly [V, ...V[]]>(values: Values): UnionSchema<I, Values[number]>;
94
- array(): ArraySchema<I, O[]>;
95
- instanceOf<C extends new (...args: any[]) => any>(constructor: C): InstanceOfSchema<I, InstanceType<C>>;
96
- jsonSchema: any;
97
- readonly inferred: O;
98
- schema: Schema<I, O>;
99
- }
100
- declare abstract class BaseSchema<I, O> implements Schema<I, O> {
101
- abstract readonly "~standard": StandardSchemaV1.Props<I, O>;
102
- jsonSchema: any;
103
- get inferred(): O;
104
- schema: Schema<I, O>;
105
- protected _coerce: boolean;
106
- coerce(): this;
107
- optional(): OptionalSchema<I, O | undefined>;
108
- enum<V extends O & (string | number | boolean), Values extends readonly [V, ...V[]]>(values: Values): UnionSchema<I, Values[number]>;
109
- array(): ArraySchema<I, O[]>;
110
- instanceOf<C extends new (...args: any[]) => any>(constructor: C): InstanceOfSchema<I, InstanceType<C>>;
111
- }
112
- declare class StringSchemaType extends BaseSchema<unknown, string> {
113
- readonly type: SchemaPrimitive;
114
- private _validateUUID;
115
- private _validateRegex;
116
- private _validateEmail;
117
- private _validatePhone;
118
- private _validateDomain;
119
- private _requireHttpOrHttps;
120
- private _minLength?;
121
- private _maxLength?;
122
- constructor();
123
- primitive(): SchemaPrimitive;
124
- minLength(n: number): StringSchemaType;
125
- maxLength(n: number): StringSchemaType;
126
- uuid(): StringSchemaType;
127
- regex(regex: RegExp): StringSchemaType;
128
- email(): StringSchemaType;
129
- phone(): StringSchemaType;
130
- domain(requireHttpOrHttps?: boolean): StringSchemaType;
131
- readonly "~standard": StandardSchemaV1.Props<unknown, string>;
132
- private _isValidUUID;
133
- private _isValidRegex;
134
- private _isValidEmail;
135
- private _isValidPhone;
136
- private _isValidDomain;
137
- }
138
- declare class NumberSchemaType extends BaseSchema<unknown, number> {
139
- readonly type: SchemaPrimitive;
140
- private _min?;
141
- private _max?;
142
- constructor();
143
- primitive(): SchemaPrimitive;
144
- min(n: number): NumberSchemaType;
145
- max(n: number): NumberSchemaType;
146
- readonly "~standard": StandardSchemaV1.Props<unknown, number>;
147
- }
148
- declare class BooleanSchemaType extends BaseSchema<unknown, boolean> {
149
- readonly type: SchemaPrimitive;
150
- constructor();
151
- primitive(): SchemaPrimitive;
152
- readonly "~standard": StandardSchemaV1.Props<unknown, boolean>;
153
- }
154
- declare class AnySchemaType extends BaseSchema<unknown, any> {
155
- readonly type: SchemaPrimitive;
156
- readonly "~standard": StandardSchemaV1.Props<unknown, any>;
157
- }
158
- declare class LiteralSchema<I, T extends string | number | boolean> extends BaseSchema<I, T> {
159
- private readonly value;
160
- constructor(value: T);
161
- readonly "~standard": StandardSchemaV1.Props<I, T>;
162
- }
163
- declare class OptionalSchema<I, O> extends BaseSchema<I, O | undefined> {
164
- private readonly innerSchema;
165
- constructor(schema: Schema<I, O>);
166
- readonly "~standard": StandardSchemaV1.Props<I, O | undefined>;
167
- }
168
- declare class NullSchemaType extends BaseSchema<unknown, null> {
169
- readonly type = "null";
170
- constructor();
171
- readonly "~standard": StandardSchemaV1.Props<unknown, null>;
172
- }
173
- declare class UnionSchema<I, O> extends BaseSchema<I, O> {
174
- private readonly schemas;
175
- constructor(...schemas: Schema<I, any>[]);
176
- readonly "~standard": StandardSchemaV1.Props<I, O>;
177
- }
178
- declare class ArraySchema<I, O extends any[]> extends BaseSchema<I, O> {
179
- private readonly innerSchema;
180
- constructor(schema: Schema<I, O[number]>);
181
- readonly "~standard": StandardSchemaV1.Props<I, O>;
182
- }
183
- declare class InstanceOfSchema<I, O> extends BaseSchema<I, O> {
184
- private readonly innerSchema;
185
- private readonly classConstructor;
186
- constructor(schema: Schema<I, any>, classConstructor: new (...args: any[]) => any);
187
- readonly "~standard": StandardSchemaV1.Props<I, O>;
188
- }
189
- declare class ObjectSchemaType<T extends Record<string, unknown>> extends BaseSchema<unknown, T> {
190
- readonly definition: SchemaDefinition;
191
- constructor(definition: SchemaDefinition);
192
- readonly "~standard": StandardSchemaV1.Props<unknown, T>;
193
- }
194
- type AnySchema = SchemaPrimitive | BaseSchema<any, any> | SchemaDefinition;
195
- declare function toStandard<T>(schema: AnySchema): Schema<unknown, T>;
196
- /**
197
- * Create standard schema types
198
- * @returns {typeof h} Standard schema types
199
- */
200
- declare const h: {
201
- /**
202
- * Create string schema type
203
- * @returns {StringSchemaType} String schema type
204
- */
205
- string: () => StringSchemaType;
206
- /**
207
- * Create number schema type
208
- * @returns {NumberSchemaType} Number schema type
209
- */
210
- number: () => NumberSchemaType;
211
- /**
212
- * Create boolean schema type
213
- * @returns {BooleanSchemaType} Boolean schema type
214
- */
215
- boolean: () => BooleanSchemaType;
216
- /**
217
- * Create null schema type
218
- * @returns {NullSchemaType} Null schema type
219
- */
220
- null: () => NullSchemaType;
221
- /**
222
- * Create any schema type
223
- * @returns {AnySchemaType} Any schema type
224
- */
225
- any: () => AnySchemaType;
226
- /**
227
- * Create literal schema type
228
- * @param {T} value - Literal value
229
- * @returns {LiteralSchema<unknown, T>} Literal schema type
230
- */
231
- literal: <T extends string | number | boolean>(value: T) => LiteralSchema<unknown, T>;
232
- /**
233
- * Create object schema type
234
- * @param {S} [schemaDef] - Schema definition
235
- * @returns {ObjectSchemaType<InferObject<S>>} Object schema type
236
- */
237
- object: <S extends SchemaDefinition>(schemaDef?: S) => ObjectSchemaType<InferObject<S>>;
238
- /**
239
- * Create array schema type
240
- * @param {S} schema - Schema
241
- * @returns {ArraySchema<unknown, InferSchema<S>[]>} Array schema type
242
- */
243
- array: <S extends AnySchema>(schema: S) => ArraySchema<unknown, SchemaType<S>[]>;
244
- /**
245
- * Create enum schema type from a list of string, number or boolean values.
246
- * @param {Values} values - An array of literal values.
247
- * @returns {UnionSchema<unknown, Values[number]>} A schema that validates against one of the provided literal values.
248
- */
249
- enum: <T extends string | number | boolean, Values extends readonly [T, ...T[]]>(values: Values) => UnionSchema<unknown, Values[number]>;
250
- /**
251
- * Create optional schema type
252
- * @param {S} schema - Schema
253
- * @returns {OptionalSchema<unknown, InferSchema<S> | undefined>} Optional schema type
254
- */
255
- optional: <S extends AnySchema>(schema: S) => OptionalSchema<unknown, InferSchema<S> | undefined>;
256
- /**
257
- * Create options schema type
258
- * @param {S} schemas - Schemas
259
- * @returns {UnionSchema<unknown, InferSchema<S[number]>>} Options schema type
260
- */
261
- options: <S extends AnySchema[]>(...schemas: S) => UnionSchema<unknown, InferSchema<S[number]>>;
262
- /**
263
- * Create instance of schema type
264
- * @param {C} constructor - Constructor function
265
- * @returns {InstanceOfSchema<unknown, InstanceType<C>>} Instance of schema type
266
- */
267
- instanceOf: <C extends new (...args: any[]) => any>(constructor: C) => InstanceOfSchema<unknown, InstanceType<C>>;
268
- /**
269
- * Create UUID schema type
270
- * @returns {StringSchemaType} UUID schema type
271
- */
272
- uuid: () => StringSchemaType;
273
- /**
274
- * Create regex schema type
275
- * @param {RegExp} regex - Regex
276
- * @returns {StringSchemaType} Regex schema type
277
- */
278
- regex: (regex: RegExp) => StringSchemaType;
279
- /**
280
- * Create email schema type
281
- * @returns {StringSchemaType} Email schema type
282
- */
283
- email: () => StringSchemaType;
284
- /**
285
- * Create phone schema type
286
- * @returns {StringSchemaType} Phone schema type
287
- */
288
- phone: () => StringSchemaType;
289
- /** Create domain schema type
290
- * @param {boolean} requireHttpOrHttps - Require http or https
291
- * @returns {StringSchemaType} Domain schema type
292
- */
293
- domain: (requireHttpOrHttps?: boolean) => StringSchemaType;
294
- /**
295
- * Convert schema to standard schema
296
- * @param {AnySchema} schema - Schema
297
- * @returns {Schema<unknown, any>} Standard schema
298
- */
299
- toStandard: typeof toStandard;
300
- };
301
-
302
- export { type AnySchema, AnySchemaType, ArraySchema, BaseSchema, BooleanSchemaType, InstanceOfSchema, LiteralSchema, NullSchemaType, NumberSchemaType, ObjectSchemaType, OptionalSchema, StringSchemaType, UnionSchema, h };
package/dist/index.js DELETED
@@ -1 +0,0 @@
1
- "use strict";var O=Object.defineProperty;var k=Object.getOwnPropertyDescriptor;var T=Object.getOwnPropertyNames;var j=Object.prototype.hasOwnProperty;var V=(t,e)=>{for(var n in e)O(t,n,{get:e[n],enumerable:!0})},_=(t,e,n,r)=>{if(e&&typeof e=="object"||typeof e=="function")for(let a of T(e))!j.call(t,a)&&a!==n&&O(t,a,{get:()=>e[a],enumerable:!(r=k(e,a))||r.enumerable});return t};var P=t=>_(O({},"__esModule",{value:!0}),t);var K={};V(K,{AnySchemaType:()=>b,ArraySchema:()=>x,BaseSchema:()=>i,BooleanSchemaType:()=>p,InstanceOfSchema:()=>I,LiteralSchema:()=>l,NullSchemaType:()=>w,NumberSchemaType:()=>S,ObjectSchemaType:()=>f,OptionalSchema:()=>u,StringSchemaType:()=>d,UnionSchema:()=>y,h:()=>m});module.exports=P(K);var i=class{jsonSchema={};get inferred(){return null}schema=this;_coerce=!1;coerce(){return this._coerce=!0,this}optional(){return new u(this)}enum(e){let n=e.map(r=>new l(r));return new y(...n)}array(){return new x(this)}instanceOf(e){return new I(this,e)}};function R(t,e){return typeof e=="string"&&t==="string"||typeof e=="number"&&t==="number"&&!Number.isNaN(e)||typeof e=="boolean"&&t==="boolean"}var d=class t extends i{type="string";_validateUUID=!1;_validateRegex=!1;_validateEmail=!1;_validatePhone=!1;_validateDomain=!1;_requireHttpOrHttps=!1;_minLength;_maxLength;constructor(){super(),this.jsonSchema={type:"string"}}primitive(){return this.type}minLength(e){let n=new t;return Object.assign(n,this),n._minLength=e,n.jsonSchema={...this.jsonSchema,minLength:e},n}maxLength(e){let n=new t;return Object.assign(n,this),n._maxLength=e,n.jsonSchema={...this.jsonSchema,maxLength:e},n}uuid(){let e=new t;return e._validateUUID=!0,e.jsonSchema={...this.jsonSchema,format:"uuid"},e}regex(e){let n=new t;return n._validateRegex=!0,n.jsonSchema={...this.jsonSchema,pattern:e.source},n}email(){let e=new t;return e._validateEmail=!0,e.jsonSchema={...this.jsonSchema,format:"email"},e}phone(){let e=new t;return e._validatePhone=!0,e.jsonSchema={...this.jsonSchema,format:"phone"},e}domain(e=!0){let n=new t;return n._validateDomain=!0,n.jsonSchema={...this.jsonSchema,format:"domain"},n._requireHttpOrHttps=e,n}"~standard"={version:1,vendor:"h-schema",validate:e=>(this._coerce&&typeof e!="string"&&(e=String(e)),typeof e!="string"?{issues:[{message:"Expected string, received "+typeof e}]}:this._minLength!==void 0&&e.length<this._minLength?{issues:[{message:`String shorter than ${this._minLength}`}]}:this._maxLength!==void 0&&e.length>this._maxLength?{issues:[{message:`String longer than ${this._maxLength}`}]}:this._validateUUID&&!this._isValidUUID(e)?{issues:[{message:"Invalid UUID format"}]}:this._validateRegex&&!this._isValidRegex(e)?{issues:[{message:"Invalid regex format"}]}:this._validateEmail&&!this._isValidEmail(e)?{issues:[{message:"Invalid email format"}]}:this._validatePhone&&!this._isValidPhone(e)?{issues:[{message:"Invalid phone number format"}]}:this._validateDomain&&!this._isValidDomain(e)?{issues:[{message:"Invalid domain format"}]}:{value:e}),types:{input:{},output:{}}};_isValidUUID(e){return/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/i.test(e)}_isValidRegex(e){return new RegExp(this.jsonSchema.pattern).test(e)}_isValidEmail(e){return/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(e)}_isValidPhone(e){return/^\+?[0-9]{7,15}$/.test(e)}_isValidDomain(e){let n=/^[a-z0-9]+([-.]{1}[a-z0-9]+)*\.[a-z]{2,6}$/;return this._requireHttpOrHttps&&(n=/^https?:\/\/[a-z0-9]+([-.]{1}[a-z0-9]+)*\.[a-z]{2,6}$/),n.test(e)}},S=class t extends i{type="number";_min;_max;constructor(){super(),this.jsonSchema={type:"number"}}primitive(){return this.type}min(e){let n=new t;return Object.assign(n,this),n._min=e,n.jsonSchema={...this.jsonSchema,minimum:e},n}max(e){let n=new t;return Object.assign(n,this),n._max=e,n.jsonSchema={...this.jsonSchema,maximum:e},n}"~standard"={version:1,vendor:"h-schema",validate:e=>{if(this._coerce&&typeof e!="number"){let n=Number(e);Number.isNaN(n)||(e=n)}return typeof e!="number"||Number.isNaN(e)?{issues:[{message:"Expected number, received "+typeof e}]}:this._min!==void 0&&e<this._min?{issues:[{message:`Number less than ${this._min}`}]}:this._max!==void 0&&e>this._max?{issues:[{message:`Number greater than ${this._max}`}]}:{value:e}},types:{input:{},output:{}}}},p=class extends i{type="boolean";constructor(){super(),this.jsonSchema={type:"boolean"}}primitive(){return this.type}"~standard"={version:1,vendor:"h-schema",validate:e=>(this._coerce&&typeof e!="boolean"&&(e==="true"||e===1||e==="1"?e=!0:(e==="false"||e===0||e==="0")&&(e=!1)),typeof e!="boolean"?{issues:[{message:`Expected boolean, received ${typeof e}`}]}:{value:e}),types:{input:{},output:{}}}},b=class extends i{type="any";"~standard"={version:1,vendor:"h-schema",validate:e=>({value:e}),types:{input:{},output:{}}}},l=class extends i{value;constructor(e){super(),this.value=e,this.jsonSchema={const:e,type:typeof e}}"~standard"={version:1,vendor:"h-schema",validate:e=>e!==this.value?{issues:[{message:`Expected literal value ${this.value}, received ${e}`}]}:{value:e},types:{input:{},output:{}}}},u=class extends i{innerSchema;constructor(e){super(),this.innerSchema=e,this.jsonSchema={...e.jsonSchema}}"~standard"={version:1,vendor:"h-schema",validate:async e=>e==null?{value:void 0}:await this.innerSchema["~standard"].validate(e),types:{input:{},output:{}}}},w=class extends i{type="null";constructor(){super(),this.jsonSchema={type:"null"}}"~standard"={version:1,vendor:"h-schema",validate:e=>e!==null?{issues:[{message:`Expected null, received ${e===void 0?"undefined":typeof e}`}]}:{value:null},types:{input:{},output:{}}}},y=class extends i{schemas;constructor(...e){super(),this.schemas=e,this.jsonSchema={anyOf:e.map(n=>n.jsonSchema)}}"~standard"={version:1,vendor:"h-schema",validate:async e=>{let n=[];for(let r of this.schemas){let a=await r["~standard"].validate(e);if(!("issues"in a))return{value:a.value};n.push(...a.issues)}return{issues:n}},types:{input:{},output:{}}}},x=class extends i{innerSchema;constructor(e){super(),this.innerSchema=e,this.jsonSchema={type:"array",items:e.jsonSchema}}"~standard"={version:1,vendor:"h-schema",validate:async e=>{if(!Array.isArray(e))return{issues:[{message:"Expected array, received "+typeof e}]};let n=await Promise.all(e.map(async(a,s)=>{let o=await this.innerSchema["~standard"].validate(a);return"issues"in o?{index:s,issues:o.issues?.map(h=>({...h,path:h.path?[s,...h.path]:[s]}))}:{index:s,value:o.value}})),r=n.filter(a=>"issues"in a);return r.length>0?{issues:r.flatMap(a=>a.issues)}:{value:n.map(a=>"value"in a?a.value:null)}},types:{input:{},output:{}}}},I=class extends i{innerSchema;classConstructor;constructor(e,n){super(),this.innerSchema=e,this.classConstructor=n,this.jsonSchema={...e.jsonSchema,instanceOf:n.name}}"~standard"={version:1,vendor:"h-schema",validate:async e=>e instanceof this.classConstructor?await this.innerSchema["~standard"].validate(e):{issues:[{message:`Expected instance of ${this.classConstructor.name}`}]},types:{input:{},output:{}}}},f=class extends i{definition;constructor(e){super(),this.definition=e;let n={},r=[];for(let a in e){let s=e[a];s instanceof u||r.push(a),typeof s=="string"?n[a]={type:s}:s instanceof i?n[a]=s.jsonSchema:typeof s=="object"&&s!==null&&(n[a]={type:"object",properties:{}})}this.jsonSchema={type:"object",properties:n,required:r.length>0?r:void 0}}"~standard"={version:1,vendor:"h-schema",validate:async e=>{if(typeof e!="object"||e===null||Array.isArray(e))return{issues:[{message:"Expected object, received "+(e===null?"null":Array.isArray(e)?"array":typeof e)}]};let n=e,r={},a=[];for(let s in this.definition){let o=this.definition[s],h=o instanceof u;if(!(s in n)&&!h){a.push({message:`Missing required property: ${s}`,path:[s]});continue}if(s in n){if(typeof o=="string"&&o in["string","number","boolean"]){let c=o;R(c,n[s])?r[s]=n[s]:a.push({message:`Invalid type for property ${s}: expected ${c}`,path:[s]})}else if(o instanceof i){let c=await o["~standard"].validate(n[s]);"issues"in c?c.issues&&a.push(...c.issues.map(v=>({...v,path:v.path?[s,...v.path]:[s]}))):r[s]=c.value}}}return a.length>0?{issues:a}:{value:r}},types:{input:{},output:{}}}};function g(t){let e;if(t instanceof i)e=t;else if(typeof t=="string")if(t==="string")e=new d;else if(t==="number")e=new S;else if(t==="boolean")e=new p;else throw new Error("Invalid schema type provided to toStandard");else if(typeof t=="object"&&t!==null&&!Array.isArray(t))e=new f(t);else throw new Error("Invalid schema type provided to toStandard");let n={toJSONSchema:r=>r.jsonSchema};return{...e,inferred:null,"~standard":e["~standard"],jsonSchema:n.toJSONSchema(e),schema:e,optional:()=>new u(e),enum:e.enum.bind(e),array:e.array.bind(e),instanceOf:e.instanceOf.bind(e)}}var m={string:()=>new d,number:()=>new S,boolean:()=>new p,null:()=>new w,any:()=>new b,literal:t=>new l(t),object:t=>new f(t||{}),array:t=>g(t).array(),enum:t=>{if(!t||t.length===0)throw new Error("h.enum() requires a non-empty array of values.");let e=t.map(n=>m.literal(n));return m.options(...e)},optional:t=>g(t).optional(),options:(...t)=>{let e=t.map(n=>g(n).schema);return new y(...e)},instanceOf:t=>m.object({}).instanceOf(t),uuid:()=>m.string().uuid(),regex:t=>m.string().regex(t),email:()=>m.string().email(),phone:()=>m.string().phone(),domain:(t=!0)=>m.string().domain(t),toStandard:g};0&&(module.exports={AnySchemaType,ArraySchema,BaseSchema,BooleanSchemaType,InstanceOfSchema,LiteralSchema,NullSchemaType,NumberSchemaType,ObjectSchemaType,OptionalSchema,StringSchemaType,UnionSchema,h});