@esmj/schema 0.3.2 → 0.3.3

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/index.d.mts CHANGED
@@ -50,7 +50,7 @@ interface ObjectSchemaInterface<T extends Record<string, SchemaType>> extends Sc
50
50
  }
51
51
  type SchemaType = StringSchemaInterface | SchemaInterface<unknown, unknown> | SchemaInterface<string, string> | SchemaInterface<string, string | undefined> | SchemaInterface<string, string | null> | SchemaInterface<string, string | undefined | null> | ObjectSchemaInterface<Record<string, SchemaType>> | SchemaInterface<object, object> | SchemaInterface<object, object | undefined> | SchemaInterface<object, object | null> | SchemaInterface<object, object | undefined | null> | NumberSchemaInterface | SchemaInterface<number, number> | SchemaInterface<number, number | undefined> | SchemaInterface<number, number | null> | SchemaInterface<number, number | undefined | null> | BooleanSchemaInterface | SchemaInterface<boolean, boolean> | SchemaInterface<boolean, boolean | undefined> | SchemaInterface<boolean, boolean | null> | SchemaInterface<boolean, boolean | undefined | null> | DateSchemaInterface | SchemaInterface<Date, Date> | SchemaInterface<Date, Date | undefined> | SchemaInterface<Date, Date | null> | SchemaInterface<Date, Date | undefined | null> | EnumSchemaInterface<string> | UnionSchemaInterface<Array<SchemaInterface<unknown, unknown>>> | ArraySchemaInterface<StringSchemaInterface | ObjectSchemaInterface<Record<string, SchemaType>> | NumberSchemaInterface | BooleanSchemaInterface | DateSchemaInterface | EnumSchemaInterface<string>> | SchemaInterface<Array<unknown>, Array<unknown>> | SchemaInterface<Array<unknown>, Array<unknown> | undefined> | SchemaInterface<Array<unknown>, Array<unknown> | null> | SchemaInterface<Array<unknown>, Array<unknown> | undefined | null>;
52
52
  type ErrorMessage = string | ((value: unknown) => string);
53
- type ExtenderType = (inter: SchemaType, validation: Function, options: {
53
+ type ExtenderType = (inter: SchemaType, validation: Function, options?: {
54
54
  message: ErrorMessage;
55
55
  type: string;
56
56
  }) => SchemaType;
@@ -60,16 +60,16 @@ interface CreateSchemaInterfaceOptions {
60
60
  }
61
61
  type SchemaInterfaceOptions = Omit<CreateSchemaInterfaceOptions, 'type'>;
62
62
  declare const s: {
63
- object<T extends Record<string, SchemaType>>(definition: { [Property in keyof T]: T[Property]; }, options: SchemaInterfaceOptions): ObjectSchemaInterface<T>;
64
- string(options: SchemaInterfaceOptions): StringSchemaInterface;
65
- number(options: SchemaInterfaceOptions): NumberSchemaInterface;
66
- boolean(options: SchemaInterfaceOptions): BooleanSchemaInterface;
67
- date(options: SchemaInterfaceOptions): DateSchemaInterface;
68
- enum(definition: Readonly<Array<string>>, options: SchemaInterfaceOptions): EnumSchemaInterface<(typeof definition)[number]>;
69
- array<T extends SchemaType>(definition: T, options: SchemaInterfaceOptions): ArraySchemaInterface<T>;
63
+ object<T extends Record<string, SchemaType>>(definition: { [Property in keyof T]: T[Property]; }, options?: SchemaInterfaceOptions): ObjectSchemaInterface<T>;
64
+ string(options?: SchemaInterfaceOptions): StringSchemaInterface;
65
+ number(options?: SchemaInterfaceOptions): NumberSchemaInterface;
66
+ boolean(options?: SchemaInterfaceOptions): BooleanSchemaInterface;
67
+ date(options?: SchemaInterfaceOptions): DateSchemaInterface;
68
+ enum(definition: Readonly<Array<string>>, options?: SchemaInterfaceOptions): EnumSchemaInterface<(typeof definition)[number]>;
69
+ array<T extends SchemaType>(definition: T, options?: SchemaInterfaceOptions): ArraySchemaInterface<T>;
70
70
  any(): any;
71
71
  preprocess<T extends SchemaType>(callback: Function, schema: T): T;
72
- union<T extends Array<SchemaType>>(definitions: T, options: SchemaInterfaceOptions): UnionSchemaInterface<T>;
72
+ union<T extends Array<SchemaType>>(definitions: T, options?: SchemaInterfaceOptions): UnionSchemaInterface<T>;
73
73
  };
74
74
  declare function extend(callback: ExtenderType): void;
75
75
  type Infer<T> = T extends SchemaType ? ReturnType<T['parse']> : unknown;
package/dist/index.d.ts CHANGED
@@ -50,7 +50,7 @@ interface ObjectSchemaInterface<T extends Record<string, SchemaType>> extends Sc
50
50
  }
51
51
  type SchemaType = StringSchemaInterface | SchemaInterface<unknown, unknown> | SchemaInterface<string, string> | SchemaInterface<string, string | undefined> | SchemaInterface<string, string | null> | SchemaInterface<string, string | undefined | null> | ObjectSchemaInterface<Record<string, SchemaType>> | SchemaInterface<object, object> | SchemaInterface<object, object | undefined> | SchemaInterface<object, object | null> | SchemaInterface<object, object | undefined | null> | NumberSchemaInterface | SchemaInterface<number, number> | SchemaInterface<number, number | undefined> | SchemaInterface<number, number | null> | SchemaInterface<number, number | undefined | null> | BooleanSchemaInterface | SchemaInterface<boolean, boolean> | SchemaInterface<boolean, boolean | undefined> | SchemaInterface<boolean, boolean | null> | SchemaInterface<boolean, boolean | undefined | null> | DateSchemaInterface | SchemaInterface<Date, Date> | SchemaInterface<Date, Date | undefined> | SchemaInterface<Date, Date | null> | SchemaInterface<Date, Date | undefined | null> | EnumSchemaInterface<string> | UnionSchemaInterface<Array<SchemaInterface<unknown, unknown>>> | ArraySchemaInterface<StringSchemaInterface | ObjectSchemaInterface<Record<string, SchemaType>> | NumberSchemaInterface | BooleanSchemaInterface | DateSchemaInterface | EnumSchemaInterface<string>> | SchemaInterface<Array<unknown>, Array<unknown>> | SchemaInterface<Array<unknown>, Array<unknown> | undefined> | SchemaInterface<Array<unknown>, Array<unknown> | null> | SchemaInterface<Array<unknown>, Array<unknown> | undefined | null>;
52
52
  type ErrorMessage = string | ((value: unknown) => string);
53
- type ExtenderType = (inter: SchemaType, validation: Function, options: {
53
+ type ExtenderType = (inter: SchemaType, validation: Function, options?: {
54
54
  message: ErrorMessage;
55
55
  type: string;
56
56
  }) => SchemaType;
@@ -60,16 +60,16 @@ interface CreateSchemaInterfaceOptions {
60
60
  }
61
61
  type SchemaInterfaceOptions = Omit<CreateSchemaInterfaceOptions, 'type'>;
62
62
  declare const s: {
63
- object<T extends Record<string, SchemaType>>(definition: { [Property in keyof T]: T[Property]; }, options: SchemaInterfaceOptions): ObjectSchemaInterface<T>;
64
- string(options: SchemaInterfaceOptions): StringSchemaInterface;
65
- number(options: SchemaInterfaceOptions): NumberSchemaInterface;
66
- boolean(options: SchemaInterfaceOptions): BooleanSchemaInterface;
67
- date(options: SchemaInterfaceOptions): DateSchemaInterface;
68
- enum(definition: Readonly<Array<string>>, options: SchemaInterfaceOptions): EnumSchemaInterface<(typeof definition)[number]>;
69
- array<T extends SchemaType>(definition: T, options: SchemaInterfaceOptions): ArraySchemaInterface<T>;
63
+ object<T extends Record<string, SchemaType>>(definition: { [Property in keyof T]: T[Property]; }, options?: SchemaInterfaceOptions): ObjectSchemaInterface<T>;
64
+ string(options?: SchemaInterfaceOptions): StringSchemaInterface;
65
+ number(options?: SchemaInterfaceOptions): NumberSchemaInterface;
66
+ boolean(options?: SchemaInterfaceOptions): BooleanSchemaInterface;
67
+ date(options?: SchemaInterfaceOptions): DateSchemaInterface;
68
+ enum(definition: Readonly<Array<string>>, options?: SchemaInterfaceOptions): EnumSchemaInterface<(typeof definition)[number]>;
69
+ array<T extends SchemaType>(definition: T, options?: SchemaInterfaceOptions): ArraySchemaInterface<T>;
70
70
  any(): any;
71
71
  preprocess<T extends SchemaType>(callback: Function, schema: T): T;
72
- union<T extends Array<SchemaType>>(definitions: T, options: SchemaInterfaceOptions): UnionSchemaInterface<T>;
72
+ union<T extends Array<SchemaType>>(definitions: T, options?: SchemaInterfaceOptions): UnionSchemaInterface<T>;
73
73
  };
74
74
  declare function extend(callback: ExtenderType): void;
75
75
  type Infer<T> = T extends SchemaType ? ReturnType<T['parse']> : unknown;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@esmj/schema",
3
- "version": "0.3.2",
3
+ "version": "0.3.3",
4
4
  "description": "Tiny extendable package for schema validation.",
5
5
  "keywords": [
6
6
  "schema",