Comparing version 3.0.5 to 3.1.0
@@ -1,10 +0,8 @@ | ||
import { prettify } from "awesome-ajv-errors/dist/index-browser.js"; | ||
import { styledPrettify } from "awesome-ajv-errors/dist/index-try-styled.js"; | ||
import { prettify } from "awesome-ajv-errors/plain"; | ||
import { styledPrettify } from "awesome-ajv-errors/try-styled"; | ||
import { setPrettify } from "./ajv-errors.js"; | ||
import { getSuretypeOptions, setSuretypeOptions } from "./options.js"; | ||
setPrettify(prettify); | ||
styledPrettify | ||
.then(prettify => { | ||
styledPrettify.then(prettify => { | ||
var _a, _b, _c; | ||
setPrettify(prettify); | ||
// Coerce stylings to true (unless already configured by the user) | ||
@@ -16,2 +14,3 @@ const opts = getSuretypeOptions(); | ||
setSuretypeOptions(opts); | ||
setPrettify(prettify); | ||
}); |
@@ -1,3 +0,3 @@ | ||
import { prettify } from "awesome-ajv-errors/dist/index-node.js"; | ||
import { prettify } from "awesome-ajv-errors"; | ||
import { setPrettify } from "./ajv-errors.js"; | ||
setPrettify(prettify); |
@@ -8,3 +8,3 @@ import { CoreValidator } from "./validators/core/validator.js"; | ||
} | ||
export declare type TopLevelAnnotations = Omit<Annotations, 'name'> & Required<Pick<Annotations, 'name'>>; | ||
export type TopLevelAnnotations = Omit<Annotations, 'name'> & Required<Pick<Annotations, 'name'>>; | ||
export declare class AnnotationsHolder { | ||
@@ -11,0 +11,0 @@ options: Annotations; |
@@ -46,3 +46,3 @@ import { CoreValidator } from "../validators/core/validator.js"; | ||
export declare const recursiveUnCast: <T>(value: T) => RecursiveValue; | ||
export declare const raw: <T = unknown>(jsonSchema: any, fragment?: string | undefined) => CoreValidator<T>; | ||
export declare const raw: <T = unknown>(jsonSchema: any, fragment?: string) => CoreValidator<T>; | ||
export declare function retype<T extends CoreValidator<unknown>>(validator: T): { | ||
@@ -49,0 +49,0 @@ as<U>(): TypeOf<T, false> extends U ? CoreValidator<U> : never; |
@@ -24,3 +24,3 @@ import type { ExportRefMethod, OnTopLevelNameConflict, OnNonSuretypeValidator } from "./types.js"; | ||
export declare function extractJsonSchema(validators: Array<CoreValidator<unknown>>, { refMethod, onTopLevelNameConflict, onNonSuretypeValidator, }?: ExtractJsonSchemaOptions): ExtractedJsonSchema; | ||
export declare type ExtractSingleSchemaResult = { | ||
export type ExtractSingleSchemaResult = { | ||
schema: Record<string, any>; | ||
@@ -27,0 +27,0 @@ fragment?: undefined; |
@@ -44,5 +44,5 @@ import Ajv from "ajv"; | ||
} | ||
export declare type ValidateFunction = (value: any) => ValidationResult; | ||
export declare type SimpleValidateFunction<T> = (value: any) => value is T; | ||
export declare type EnsureFunction<T> = <U = T>(value: any) => T extends U ? U : never; | ||
export type ValidateFunction = (value: any) => ValidationResult; | ||
export type SimpleValidateFunction<T> = (value: any) => value is T; | ||
export type EnsureFunction<T> = <U = T>(value: any) => T extends U ? U : never; | ||
export declare function compile<T extends CoreValidator<unknown> = any, U = TypeOf<T>>(schema: T, opts: CompileOptionsEnsure): TypeOf<T> extends U ? EnsureFunction<U> : never; | ||
@@ -53,4 +53,4 @@ export declare function compile<T extends CoreValidator<unknown> = any>(schema: T, opts: CompileOptionsSimple): SimpleValidateFunction<TypeOf<T>>; | ||
export declare function isValid<T extends CoreValidator<unknown>>(schema: T, value: any, options?: CompileOptionsCore): value is TypeOf<T, false>; | ||
export declare function ensure<T extends CoreValidator<unknown>>(schema: T, value: any, options?: CompileOptionsCore): TypeOf<T, false> extends TypeOf<T, false> ? TypeOf<T, false> : never; | ||
export declare function ensure<T extends CoreValidator<unknown>>(schema: T, value: any, options?: CompileOptionsCore): TypeOf<T, false> extends infer T_1 ? T_1 extends TypeOf<T, false> ? T_1 extends TypeOf<T, false> ? TypeOf<T, false> : never : never : never; | ||
export declare function setSchemaDraft07(draft: any): void; | ||
export declare function validateJsonSchema(schema: {}): ValidationResult; |
@@ -1,3 +0,3 @@ | ||
export declare type ExportRefMethod = 'no-refs' | 'provided' | 'ref-all'; | ||
export declare type OnTopLevelNameConflict = 'error' | 'rename'; | ||
export declare type OnNonSuretypeValidator = 'error' | 'ignore' | 'create-name' | 'lookup'; | ||
export type ExportRefMethod = 'no-refs' | 'provided' | 'ref-all'; | ||
export type OnTopLevelNameConflict = 'error' | 'rename'; | ||
export type OnNonSuretypeValidator = 'error' | 'ignore' | 'create-name' | 'lookup'; |
import type * as Ajv from "ajv"; | ||
import { SuretypeOptions } from "./options.js"; | ||
export declare type ErrorHook = (err: ValidationError) => void; | ||
export type ErrorHook = (err: ValidationError) => void; | ||
export declare function setErrorHook(fn?: ErrorHook | undefined): void; | ||
@@ -17,3 +17,3 @@ export interface ValidationErrorData { | ||
} | ||
export declare type ValidationResult = ValidationResultInvalid | ValidationResultValid; | ||
export type ValidationResult = ValidationResultInvalid | ValidationResultValid; | ||
export interface ExplanationOptions extends SuretypeOptions { | ||
@@ -20,0 +20,0 @@ schema: unknown; |
@@ -6,4 +6,4 @@ import type { OptionalFrom, Last, Rest, Fill, ReverseRest, Overwrite } from "meta-types"; | ||
import type { TypeOf, IsRequired } from "./functional.js"; | ||
export declare type FirstOptionalIndex<T extends readonly unknown[], N extends number = T['length']> = T extends [] ? 0 : IsRequired<Last<T>> extends true ? N : FirstOptionalIndex<ReverseRest<T>>; | ||
export declare type ExtractArray<T extends readonly unknown[]> = { | ||
export type FirstOptionalIndex<T extends readonly unknown[], N extends number = T['length']> = T extends [] ? 0 : IsRequired<Last<T>> extends true ? N : FirstOptionalIndex<ReverseRest<T>>; | ||
export type ExtractArray<T extends readonly unknown[]> = { | ||
R: [TypeOf<T[0], true>, ...ExtractArray<Rest<T>>]; | ||
@@ -13,10 +13,10 @@ 1: [TypeOf<T[0], true>]; | ||
}[T['length'] extends 0 ? 0 : T['length'] extends 1 ? 1 : 'R']; | ||
export declare type ArrayOf<T extends readonly unknown[], N extends number = FirstOptionalIndex<T>> = OptionalFrom<ExtractArray<T>, N>; | ||
export declare type ArrayOfWithRest<T extends readonly unknown[], Rest, N extends number = FirstOptionalIndex<T>> = ArrayOfWithRestFilled<Overwrite<Fill<N, Rest>, ExtractArray<T>>, Rest, N>; | ||
declare type ArrayOfWithRestFilled<T extends readonly unknown[], Rest, N extends number> = OptionalFrom<T, N> | [...T, ...Rest[]]; | ||
export declare type EnsureArray<T> = T extends Array<infer U> ? T : [T]; | ||
export type ArrayOf<T extends readonly unknown[], N extends number = FirstOptionalIndex<T>> = OptionalFrom<ExtractArray<T>, N>; | ||
export type ArrayOfWithRest<T extends readonly unknown[], Rest, N extends number = FirstOptionalIndex<T>> = ArrayOfWithRestFilled<Overwrite<Fill<N, Rest>, ExtractArray<T>>, Rest, N>; | ||
type ArrayOfWithRestFilled<T extends readonly unknown[], Rest, N extends number> = OptionalFrom<T, N> | [...T, ...Rest[]]; | ||
export type EnsureArray<T> = T extends Array<infer U> ? T : [T]; | ||
export interface TupleFunction { | ||
<T extends BaseValidator<unknown>[]>(types: [...T]): TupleValidator<ArrayOf<T>, typeof types, FirstOptionalIndex<T>, false>; | ||
} | ||
export declare type ArrayFunction = <U extends BaseValidator<unknown>>(itemType?: U) => ArrayValidator<Array<TypeOf<U>>>; | ||
export type ArrayFunction = <U extends BaseValidator<unknown>>(itemType?: U) => ArrayValidator<Array<TypeOf<U>>>; | ||
export {}; |
@@ -449,3 +449,3 @@ import { Type } from "../types.js"; | ||
anyOf?: undefined; | ||
default: T; | ||
default: T & ({} | null); | ||
examples?: string[] | undefined; | ||
@@ -463,3 +463,3 @@ description?: string | undefined; | ||
anyOf?: undefined; | ||
default: T; | ||
default: T & ({} | null); | ||
examples?: string[] | undefined; | ||
@@ -477,3 +477,3 @@ description?: string | undefined; | ||
anyOf?: undefined; | ||
default: T; | ||
default: T & ({} | null); | ||
examples?: string[] | undefined; | ||
@@ -491,3 +491,3 @@ description?: string | undefined; | ||
anyOf?: undefined; | ||
default: T; | ||
default: T & ({} | null); | ||
examples?: string[] | undefined; | ||
@@ -505,3 +505,3 @@ description?: string | undefined; | ||
anyOf?: undefined; | ||
default: T; | ||
default: T & ({} | null); | ||
examples?: string[] | undefined; | ||
@@ -519,3 +519,3 @@ description?: string | undefined; | ||
anyOf?: undefined; | ||
default: T; | ||
default: T & ({} | null); | ||
examples?: string[] | undefined; | ||
@@ -533,3 +533,3 @@ description?: string | undefined; | ||
anyOf?: undefined; | ||
default: T; | ||
default: T & ({} | null); | ||
examples?: string[] | undefined; | ||
@@ -547,3 +547,3 @@ description?: string | undefined; | ||
anyOf?: undefined; | ||
default: T; | ||
default: T & ({} | null); | ||
examples?: string[] | undefined; | ||
@@ -561,3 +561,3 @@ description?: string | undefined; | ||
anyOf?: undefined; | ||
default: T; | ||
default: T & ({} | null); | ||
examples?: string[] | undefined; | ||
@@ -575,3 +575,3 @@ description?: string | undefined; | ||
anyOf?: undefined; | ||
default: T; | ||
default: T & ({} | null); | ||
examples?: string[] | undefined; | ||
@@ -589,3 +589,3 @@ description?: string | undefined; | ||
anyOf?: undefined; | ||
default: T; | ||
default: T & ({} | null); | ||
examples?: string[] | undefined; | ||
@@ -603,3 +603,3 @@ description?: string | undefined; | ||
anyOf?: undefined; | ||
default: T; | ||
default: T & ({} | null); | ||
examples?: string[] | undefined; | ||
@@ -617,3 +617,3 @@ description?: string | undefined; | ||
anyOf?: undefined; | ||
default: T; | ||
default: T & ({} | null); | ||
examples?: string[] | undefined; | ||
@@ -631,3 +631,3 @@ description?: string | undefined; | ||
anyOf?: undefined; | ||
default: T; | ||
default: T & ({} | null); | ||
examples?: string[] | undefined; | ||
@@ -645,3 +645,3 @@ description?: string | undefined; | ||
anyOf?: undefined; | ||
default: T; | ||
default: T & ({} | null); | ||
examples?: string[] | undefined; | ||
@@ -659,3 +659,3 @@ description?: string | undefined; | ||
anyOf?: undefined; | ||
default: T; | ||
default: T & ({} | null); | ||
examples?: string[] | undefined; | ||
@@ -673,3 +673,3 @@ description?: string | undefined; | ||
anyOf: Omit<any, "type">[]; | ||
default: T; | ||
default: T & ({} | null); | ||
examples?: string[] | undefined; | ||
@@ -687,3 +687,3 @@ description?: string | undefined; | ||
anyOf: Omit<any, "type">[]; | ||
default: T; | ||
default: T & ({} | null); | ||
examples?: string[] | undefined; | ||
@@ -701,3 +701,3 @@ description?: string | undefined; | ||
anyOf: Omit<any, "type">[]; | ||
default: T; | ||
default: T & ({} | null); | ||
examples?: string[] | undefined; | ||
@@ -715,3 +715,3 @@ description?: string | undefined; | ||
anyOf: Omit<any, "type">[]; | ||
default: T; | ||
default: T & ({} | null); | ||
examples?: string[] | undefined; | ||
@@ -729,3 +729,3 @@ description?: string | undefined; | ||
anyOf: Omit<any, "type">[]; | ||
default: T; | ||
default: T & ({} | null); | ||
examples?: string[] | undefined; | ||
@@ -743,3 +743,3 @@ description?: string | undefined; | ||
anyOf: Omit<any, "type">[]; | ||
default: T; | ||
default: T & ({} | null); | ||
examples?: string[] | undefined; | ||
@@ -757,3 +757,3 @@ description?: string | undefined; | ||
anyOf: Omit<any, "type">[]; | ||
default: T; | ||
default: T & ({} | null); | ||
examples?: string[] | undefined; | ||
@@ -771,3 +771,3 @@ description?: string | undefined; | ||
anyOf: Omit<any, "type">[]; | ||
default: T; | ||
default: T & ({} | null); | ||
examples?: string[] | undefined; | ||
@@ -785,3 +785,3 @@ description?: string | undefined; | ||
anyOf: Omit<any, "type">[]; | ||
default: T; | ||
default: T & ({} | null); | ||
examples?: string[] | undefined; | ||
@@ -799,3 +799,3 @@ description?: string | undefined; | ||
anyOf: Omit<any, "type">[]; | ||
default: T; | ||
default: T & ({} | null); | ||
examples?: string[] | undefined; | ||
@@ -813,3 +813,3 @@ description?: string | undefined; | ||
anyOf: Omit<any, "type">[]; | ||
default: T; | ||
default: T & ({} | null); | ||
examples?: string[] | undefined; | ||
@@ -827,3 +827,3 @@ description?: string | undefined; | ||
anyOf: Omit<any, "type">[]; | ||
default: T; | ||
default: T & ({} | null); | ||
examples?: string[] | undefined; | ||
@@ -841,3 +841,3 @@ description?: string | undefined; | ||
anyOf: Omit<any, "type">[]; | ||
default: T; | ||
default: T & ({} | null); | ||
examples?: string[] | undefined; | ||
@@ -855,3 +855,3 @@ description?: string | undefined; | ||
anyOf: Omit<any, "type">[]; | ||
default: T; | ||
default: T & ({} | null); | ||
examples?: string[] | undefined; | ||
@@ -869,3 +869,3 @@ description?: string | undefined; | ||
anyOf: Omit<any, "type">[]; | ||
default: T; | ||
default: T & ({} | null); | ||
examples?: string[] | undefined; | ||
@@ -883,3 +883,3 @@ description?: string | undefined; | ||
anyOf: Omit<any, "type">[]; | ||
default: T; | ||
default: T & ({} | null); | ||
examples?: string[] | undefined; | ||
@@ -886,0 +886,0 @@ description?: string | undefined; |
@@ -43,3 +43,3 @@ import { Type } from "../types.js"; | ||
anyOf?: undefined; | ||
default: T; | ||
default: T & ({} | null); | ||
examples?: string[] | undefined; | ||
@@ -52,3 +52,3 @@ description?: string | undefined; | ||
anyOf?: undefined; | ||
default: T; | ||
default: T & ({} | null); | ||
examples?: string[] | undefined; | ||
@@ -61,3 +61,3 @@ description?: string | undefined; | ||
anyOf: Omit<any, "type">[]; | ||
default: T; | ||
default: T & ({} | null); | ||
examples?: string[] | undefined; | ||
@@ -70,3 +70,3 @@ description?: string | undefined; | ||
anyOf: Omit<any, "type">[]; | ||
default: T; | ||
default: T & ({} | null); | ||
examples?: string[] | undefined; | ||
@@ -73,0 +73,0 @@ description?: string | undefined; |
@@ -19,12 +19,12 @@ import { CoreValidator } from "./core/validator.js"; | ||
import { RecursiveValue } from "./types.js"; | ||
export declare type IsRequired<T> = T extends RequiredValidator<infer U, infer _> ? true : false; | ||
export declare type ExtractRequired<T> = T extends RequiredValidator<infer U, infer _> ? U : never; | ||
export declare type ValuesOf<T extends {}> = T[keyof T] & unknown; | ||
export declare type FlattenObject<T> = { | ||
export type IsRequired<T> = T extends RequiredValidator<infer U, infer _> ? true : false; | ||
export type ExtractRequired<T> = T extends RequiredValidator<infer U, infer _> ? U : never; | ||
export type ValuesOf<T extends {}> = T[keyof T] & unknown; | ||
export type FlattenObject<T> = { | ||
[K in keyof T]: T[K] & unknown; | ||
}; | ||
export declare type AdditionalProperties<T, U> = FlattenObject<T & Record<string, U | ValuesOf<T>>>; | ||
export declare type TypeOf<T, InclRequired = false> = T extends ObjectValidator<infer U> ? FlattenObject<U> : T extends TupleValidator<infer U, infer V, infer N, infer A> ? U : T extends ArrayValidator<infer U> ? U : T extends StringValidator<infer U> ? U : T extends NumberValidator<infer U> ? U : T extends BooleanValidator<infer U> ? U : T extends NullValidator<infer U> ? U : T extends AnyValidator<infer U> ? U : T extends RecursiveValidator ? RecursiveValue : T extends RawValidator ? unknown : T extends AnyOfValidator<infer U> ? U : T extends AllOfValidator<infer U> ? U : T extends ElseValidator<infer U> ? U : T extends ThenValidator<infer U> ? U : T extends IfValidator<infer U> ? U : T extends ValueValidator<infer U, infer V> ? U : T extends RequiredValidator<infer U, infer _> ? InclRequired extends true ? U : never : T extends BaseValidator<infer U> ? U : T extends CoreValidator<infer U> ? U : never; | ||
export declare type Writeable<T> = { | ||
export type AdditionalProperties<T extends {}, U> = FlattenObject<T & Record<string, U | ValuesOf<T>>>; | ||
export type TypeOf<T, InclRequired = false> = T extends ObjectValidator<infer U> ? FlattenObject<U> : T extends TupleValidator<infer U, infer V, infer N, infer A> ? U : T extends ArrayValidator<infer U> ? U : T extends StringValidator<infer U> ? U : T extends NumberValidator<infer U> ? U : T extends BooleanValidator<infer U> ? U : T extends NullValidator<infer U> ? U : T extends AnyValidator<infer U> ? U : T extends RecursiveValidator ? RecursiveValue : T extends RawValidator ? unknown : T extends AnyOfValidator<infer U> ? U : T extends AllOfValidator<infer U> ? U : T extends ElseValidator<infer U> ? U : T extends ThenValidator<infer U> ? U : T extends IfValidator<infer U> ? U : T extends ValueValidator<infer U, infer V> ? U : T extends RequiredValidator<infer U, infer _> ? InclRequired extends true ? U : never : T extends BaseValidator<infer U> ? U : T extends CoreValidator<infer U> ? U : never; | ||
export type Writeable<T> = { | ||
-readonly [P in keyof T]: T[P]; | ||
}; |
@@ -43,3 +43,3 @@ import { Type } from "../types.js"; | ||
anyOf?: undefined; | ||
default: T; | ||
default: T & ({} | null); | ||
examples?: string[] | undefined; | ||
@@ -52,3 +52,3 @@ description?: string | undefined; | ||
anyOf?: undefined; | ||
default: T; | ||
default: T & ({} | null); | ||
examples?: string[] | undefined; | ||
@@ -61,3 +61,3 @@ description?: string | undefined; | ||
anyOf: Omit<any, "type">[]; | ||
default: T; | ||
default: T & ({} | null); | ||
examples?: string[] | undefined; | ||
@@ -70,3 +70,3 @@ description?: string | undefined; | ||
anyOf: Omit<any, "type">[]; | ||
default: T; | ||
default: T & ({} | null); | ||
examples?: string[] | undefined; | ||
@@ -73,0 +73,0 @@ description?: string | undefined; |
@@ -84,3 +84,3 @@ import { Type } from "../types.js"; | ||
anyOf?: undefined; | ||
default: T; | ||
default: T & ({} | null); | ||
examples?: string[] | undefined; | ||
@@ -98,3 +98,3 @@ description?: string | undefined; | ||
anyOf?: undefined; | ||
default: T; | ||
default: T & ({} | null); | ||
examples?: string[] | undefined; | ||
@@ -112,3 +112,3 @@ description?: string | undefined; | ||
anyOf: Omit<any, "type">[]; | ||
default: T; | ||
default: T & ({} | null); | ||
examples?: string[] | undefined; | ||
@@ -126,3 +126,3 @@ description?: string | undefined; | ||
anyOf: Omit<any, "type">[]; | ||
default: T; | ||
default: T & ({} | null); | ||
examples?: string[] | undefined; | ||
@@ -129,0 +129,0 @@ description?: string | undefined; |
@@ -5,9 +5,9 @@ import { CoreValidator } from "./core/validator.js"; | ||
import { TypeOf } from "./functional.js"; | ||
export declare type RequiredKeys<T extends { | ||
export type RequiredKeys<T extends { | ||
[key: string]: CoreValidator<unknown>; | ||
}> = SubType<T, RequiredValidator<any, any>>; | ||
export declare type OptionalKeys<T extends { | ||
export type OptionalKeys<T extends { | ||
[key: string]: CoreValidator<unknown>; | ||
}> = SubType<T, RequiredValidator<any, any>, true>; | ||
export declare type ExtractObject<T extends { | ||
export type ExtractObject<T extends { | ||
[key: string]: CoreValidator<unknown>; | ||
@@ -14,0 +14,0 @@ }> = { |
@@ -77,3 +77,3 @@ import { Type } from "../types.js"; | ||
anyOf?: undefined; | ||
default: T; | ||
default: T & ({} | null); | ||
examples?: string[] | undefined; | ||
@@ -89,3 +89,3 @@ description?: string | undefined; | ||
anyOf?: undefined; | ||
default: T; | ||
default: T & ({} | null); | ||
examples?: string[] | undefined; | ||
@@ -101,3 +101,3 @@ description?: string | undefined; | ||
anyOf: Omit<any, "type">[]; | ||
default: T; | ||
default: T & ({} | null); | ||
examples?: string[] | undefined; | ||
@@ -113,3 +113,3 @@ description?: string | undefined; | ||
anyOf: Omit<any, "type">[]; | ||
default: T; | ||
default: T & ({} | null); | ||
examples?: string[] | undefined; | ||
@@ -116,0 +116,0 @@ description?: string | undefined; |
@@ -5,2 +5,2 @@ /** | ||
*/ | ||
export declare type Formats = "date-time" | "time" | "date" | "email" | "idn-email" | "hostname" | "idn-hostname" | "ipv4" | "ipv6" | "uri" | "uri-reference" | "iri" | "iri-reference" | "uri-template" | "json-pointer" | "relative-json-pointer" | "regex"; | ||
export type Formats = "date-time" | "time" | "date" | "email" | "idn-email" | "hostname" | "idn-hostname" | "ipv4" | "ipv6" | "uri" | "uri-reference" | "iri" | "iri-reference" | "uri-template" | "json-pointer" | "relative-json-pointer" | "regex"; |
@@ -23,3 +23,3 @@ import { Type } from "../types.js"; | ||
protected toSchema(traverser: TreeTraverser): { | ||
format?: "regex" | "date-time" | "time" | "date" | "email" | "idn-email" | "hostname" | "idn-hostname" | "ipv4" | "ipv6" | "uri" | "uri-reference" | "iri" | "iri-reference" | "uri-template" | "json-pointer" | "relative-json-pointer" | undefined; | ||
format?: NonNullable<"regex" | "date-time" | "time" | "date" | "email" | "idn-email" | "hostname" | "idn-hostname" | "ipv4" | "ipv6" | "uri" | "uri-reference" | "iri" | "iri-reference" | "uri-template" | "json-pointer" | "relative-json-pointer"> | undefined; | ||
pattern?: string | undefined; | ||
@@ -36,3 +36,3 @@ maxLength?: number | undefined; | ||
} | { | ||
format?: "regex" | "date-time" | "time" | "date" | "email" | "idn-email" | "hostname" | "idn-hostname" | "ipv4" | "ipv6" | "uri" | "uri-reference" | "iri" | "iri-reference" | "uri-template" | "json-pointer" | "relative-json-pointer" | undefined; | ||
format?: NonNullable<"regex" | "date-time" | "time" | "date" | "email" | "idn-email" | "hostname" | "idn-hostname" | "ipv4" | "ipv6" | "uri" | "uri-reference" | "iri" | "iri-reference" | "uri-template" | "json-pointer" | "relative-json-pointer"> | undefined; | ||
pattern?: string | undefined; | ||
@@ -49,3 +49,3 @@ maxLength?: number | undefined; | ||
} | { | ||
format?: "regex" | "date-time" | "time" | "date" | "email" | "idn-email" | "hostname" | "idn-hostname" | "ipv4" | "ipv6" | "uri" | "uri-reference" | "iri" | "iri-reference" | "uri-template" | "json-pointer" | "relative-json-pointer" | undefined; | ||
format?: NonNullable<"regex" | "date-time" | "time" | "date" | "email" | "idn-email" | "hostname" | "idn-hostname" | "ipv4" | "ipv6" | "uri" | "uri-reference" | "iri" | "iri-reference" | "uri-template" | "json-pointer" | "relative-json-pointer"> | undefined; | ||
pattern?: string | undefined; | ||
@@ -62,3 +62,3 @@ maxLength?: number | undefined; | ||
} | { | ||
format?: "regex" | "date-time" | "time" | "date" | "email" | "idn-email" | "hostname" | "idn-hostname" | "ipv4" | "ipv6" | "uri" | "uri-reference" | "iri" | "iri-reference" | "uri-template" | "json-pointer" | "relative-json-pointer" | undefined; | ||
format?: NonNullable<"regex" | "date-time" | "time" | "date" | "email" | "idn-email" | "hostname" | "idn-hostname" | "ipv4" | "ipv6" | "uri" | "uri-reference" | "iri" | "iri-reference" | "uri-template" | "json-pointer" | "relative-json-pointer"> | undefined; | ||
pattern?: string | undefined; | ||
@@ -75,3 +75,3 @@ maxLength?: number | undefined; | ||
} | { | ||
format?: "regex" | "date-time" | "time" | "date" | "email" | "idn-email" | "hostname" | "idn-hostname" | "ipv4" | "ipv6" | "uri" | "uri-reference" | "iri" | "iri-reference" | "uri-template" | "json-pointer" | "relative-json-pointer" | undefined; | ||
format?: NonNullable<"regex" | "date-time" | "time" | "date" | "email" | "idn-email" | "hostname" | "idn-hostname" | "ipv4" | "ipv6" | "uri" | "uri-reference" | "iri" | "iri-reference" | "uri-template" | "json-pointer" | "relative-json-pointer"> | undefined; | ||
pattern?: string | undefined; | ||
@@ -82,3 +82,3 @@ maxLength?: number | undefined; | ||
anyOf?: undefined; | ||
default: T; | ||
default: T & ({} | null); | ||
examples?: string[] | undefined; | ||
@@ -89,3 +89,3 @@ description?: string | undefined; | ||
} | { | ||
format?: "regex" | "date-time" | "time" | "date" | "email" | "idn-email" | "hostname" | "idn-hostname" | "ipv4" | "ipv6" | "uri" | "uri-reference" | "iri" | "iri-reference" | "uri-template" | "json-pointer" | "relative-json-pointer" | undefined; | ||
format?: NonNullable<"regex" | "date-time" | "time" | "date" | "email" | "idn-email" | "hostname" | "idn-hostname" | "ipv4" | "ipv6" | "uri" | "uri-reference" | "iri" | "iri-reference" | "uri-template" | "json-pointer" | "relative-json-pointer"> | undefined; | ||
pattern?: string | undefined; | ||
@@ -96,3 +96,3 @@ maxLength?: number | undefined; | ||
anyOf?: undefined; | ||
default: T; | ||
default: T & ({} | null); | ||
examples?: string[] | undefined; | ||
@@ -103,3 +103,3 @@ description?: string | undefined; | ||
} | { | ||
format?: "regex" | "date-time" | "time" | "date" | "email" | "idn-email" | "hostname" | "idn-hostname" | "ipv4" | "ipv6" | "uri" | "uri-reference" | "iri" | "iri-reference" | "uri-template" | "json-pointer" | "relative-json-pointer" | undefined; | ||
format?: NonNullable<"regex" | "date-time" | "time" | "date" | "email" | "idn-email" | "hostname" | "idn-hostname" | "ipv4" | "ipv6" | "uri" | "uri-reference" | "iri" | "iri-reference" | "uri-template" | "json-pointer" | "relative-json-pointer"> | undefined; | ||
pattern?: string | undefined; | ||
@@ -110,3 +110,3 @@ maxLength?: number | undefined; | ||
anyOf: Omit<any, "type">[]; | ||
default: T; | ||
default: T & ({} | null); | ||
examples?: string[] | undefined; | ||
@@ -117,3 +117,3 @@ description?: string | undefined; | ||
} | { | ||
format?: "regex" | "date-time" | "time" | "date" | "email" | "idn-email" | "hostname" | "idn-hostname" | "ipv4" | "ipv6" | "uri" | "uri-reference" | "iri" | "iri-reference" | "uri-template" | "json-pointer" | "relative-json-pointer" | undefined; | ||
format?: NonNullable<"regex" | "date-time" | "time" | "date" | "email" | "idn-email" | "hostname" | "idn-hostname" | "ipv4" | "ipv6" | "uri" | "uri-reference" | "iri" | "iri-reference" | "uri-template" | "json-pointer" | "relative-json-pointer"> | undefined; | ||
pattern?: string | undefined; | ||
@@ -124,3 +124,3 @@ maxLength?: number | undefined; | ||
anyOf: Omit<any, "type">[]; | ||
default: T; | ||
default: T & ({} | null); | ||
examples?: string[] | undefined; | ||
@@ -127,0 +127,0 @@ description?: string | undefined; |
@@ -499,3 +499,3 @@ import type { If, Is, And, Extends, GreaterThan, LengthOf } from "meta-types"; | ||
anyOf?: undefined; | ||
default: T; | ||
default: T & ({} | null); | ||
examples?: string[] | undefined; | ||
@@ -514,3 +514,3 @@ description?: string | undefined; | ||
anyOf?: undefined; | ||
default: T; | ||
default: T & ({} | null); | ||
examples?: string[] | undefined; | ||
@@ -529,3 +529,3 @@ description?: string | undefined; | ||
anyOf?: undefined; | ||
default: T; | ||
default: T & ({} | null); | ||
examples?: string[] | undefined; | ||
@@ -544,3 +544,3 @@ description?: string | undefined; | ||
anyOf?: undefined; | ||
default: T; | ||
default: T & ({} | null); | ||
examples?: string[] | undefined; | ||
@@ -559,3 +559,3 @@ description?: string | undefined; | ||
anyOf?: undefined; | ||
default: T; | ||
default: T & ({} | null); | ||
examples?: string[] | undefined; | ||
@@ -574,3 +574,3 @@ description?: string | undefined; | ||
anyOf?: undefined; | ||
default: T; | ||
default: T & ({} | null); | ||
examples?: string[] | undefined; | ||
@@ -589,3 +589,3 @@ description?: string | undefined; | ||
anyOf?: undefined; | ||
default: T; | ||
default: T & ({} | null); | ||
examples?: string[] | undefined; | ||
@@ -604,3 +604,3 @@ description?: string | undefined; | ||
anyOf?: undefined; | ||
default: T; | ||
default: T & ({} | null); | ||
examples?: string[] | undefined; | ||
@@ -619,3 +619,3 @@ description?: string | undefined; | ||
anyOf?: undefined; | ||
default: T; | ||
default: T & ({} | null); | ||
examples?: string[] | undefined; | ||
@@ -634,3 +634,3 @@ description?: string | undefined; | ||
anyOf?: undefined; | ||
default: T; | ||
default: T & ({} | null); | ||
examples?: string[] | undefined; | ||
@@ -649,3 +649,3 @@ description?: string | undefined; | ||
anyOf?: undefined; | ||
default: T; | ||
default: T & ({} | null); | ||
examples?: string[] | undefined; | ||
@@ -664,3 +664,3 @@ description?: string | undefined; | ||
anyOf?: undefined; | ||
default: T; | ||
default: T & ({} | null); | ||
examples?: string[] | undefined; | ||
@@ -679,3 +679,3 @@ description?: string | undefined; | ||
anyOf?: undefined; | ||
default: T; | ||
default: T & ({} | null); | ||
examples?: string[] | undefined; | ||
@@ -694,3 +694,3 @@ description?: string | undefined; | ||
anyOf?: undefined; | ||
default: T; | ||
default: T & ({} | null); | ||
examples?: string[] | undefined; | ||
@@ -709,3 +709,3 @@ description?: string | undefined; | ||
anyOf?: undefined; | ||
default: T; | ||
default: T & ({} | null); | ||
examples?: string[] | undefined; | ||
@@ -724,3 +724,3 @@ description?: string | undefined; | ||
anyOf?: undefined; | ||
default: T; | ||
default: T & ({} | null); | ||
examples?: string[] | undefined; | ||
@@ -739,3 +739,3 @@ description?: string | undefined; | ||
anyOf: Omit<any, "type">[]; | ||
default: T; | ||
default: T & ({} | null); | ||
examples?: string[] | undefined; | ||
@@ -754,3 +754,3 @@ description?: string | undefined; | ||
anyOf: Omit<any, "type">[]; | ||
default: T; | ||
default: T & ({} | null); | ||
examples?: string[] | undefined; | ||
@@ -769,3 +769,3 @@ description?: string | undefined; | ||
anyOf: Omit<any, "type">[]; | ||
default: T; | ||
default: T & ({} | null); | ||
examples?: string[] | undefined; | ||
@@ -784,3 +784,3 @@ description?: string | undefined; | ||
anyOf: Omit<any, "type">[]; | ||
default: T; | ||
default: T & ({} | null); | ||
examples?: string[] | undefined; | ||
@@ -799,3 +799,3 @@ description?: string | undefined; | ||
anyOf: Omit<any, "type">[]; | ||
default: T; | ||
default: T & ({} | null); | ||
examples?: string[] | undefined; | ||
@@ -814,3 +814,3 @@ description?: string | undefined; | ||
anyOf: Omit<any, "type">[]; | ||
default: T; | ||
default: T & ({} | null); | ||
examples?: string[] | undefined; | ||
@@ -829,3 +829,3 @@ description?: string | undefined; | ||
anyOf: Omit<any, "type">[]; | ||
default: T; | ||
default: T & ({} | null); | ||
examples?: string[] | undefined; | ||
@@ -844,3 +844,3 @@ description?: string | undefined; | ||
anyOf: Omit<any, "type">[]; | ||
default: T; | ||
default: T & ({} | null); | ||
examples?: string[] | undefined; | ||
@@ -859,3 +859,3 @@ description?: string | undefined; | ||
anyOf: Omit<any, "type">[]; | ||
default: T; | ||
default: T & ({} | null); | ||
examples?: string[] | undefined; | ||
@@ -874,3 +874,3 @@ description?: string | undefined; | ||
anyOf: Omit<any, "type">[]; | ||
default: T; | ||
default: T & ({} | null); | ||
examples?: string[] | undefined; | ||
@@ -889,3 +889,3 @@ description?: string | undefined; | ||
anyOf: Omit<any, "type">[]; | ||
default: T; | ||
default: T & ({} | null); | ||
examples?: string[] | undefined; | ||
@@ -904,3 +904,3 @@ description?: string | undefined; | ||
anyOf: Omit<any, "type">[]; | ||
default: T; | ||
default: T & ({} | null); | ||
examples?: string[] | undefined; | ||
@@ -919,3 +919,3 @@ description?: string | undefined; | ||
anyOf: Omit<any, "type">[]; | ||
default: T; | ||
default: T & ({} | null); | ||
examples?: string[] | undefined; | ||
@@ -934,3 +934,3 @@ description?: string | undefined; | ||
anyOf: Omit<any, "type">[]; | ||
default: T; | ||
default: T & ({} | null); | ||
examples?: string[] | undefined; | ||
@@ -949,3 +949,3 @@ description?: string | undefined; | ||
anyOf: Omit<any, "type">[]; | ||
default: T; | ||
default: T & ({} | null); | ||
examples?: string[] | undefined; | ||
@@ -964,3 +964,3 @@ description?: string | undefined; | ||
anyOf: Omit<any, "type">[]; | ||
default: T; | ||
default: T & ({} | null); | ||
examples?: string[] | undefined; | ||
@@ -967,0 +967,0 @@ description?: string | undefined; |
@@ -1,9 +0,9 @@ | ||
export declare type Type = "string" | "number" | "integer" | "object" | "array" | "boolean" | "null"; | ||
export declare type AnyType = Type | "raw" | "any" | "any-of" | "all-of" | "if" | "recursive"; | ||
export declare type FilterProperties<T, Cond> = { | ||
export type Type = "string" | "number" | "integer" | "object" | "array" | "boolean" | "null"; | ||
export type AnyType = Type | "raw" | "any" | "any-of" | "all-of" | "if" | "recursive"; | ||
export type FilterProperties<T, Cond> = { | ||
[K in keyof T]: T[K] extends Cond ? K : never; | ||
}; | ||
export declare type FilterNames<T, Cond> = FilterProperties<T, Cond>[keyof T]; | ||
export declare type SubType<T, Cond, Invert = false> = Invert extends true ? Omit<T, FilterNames<T, Cond>> : Pick<T, FilterNames<T, Cond>>; | ||
export type FilterNames<T, Cond> = FilterProperties<T, Cond>[keyof T]; | ||
export type SubType<T, Cond, Invert = false> = Invert extends true ? Omit<T, FilterNames<T, Cond>> : Pick<T, FilterNames<T, Cond>>; | ||
export declare abstract class RecursiveValue { | ||
} |
@@ -53,3 +53,3 @@ import { Type } from "../types.js"; | ||
} | { | ||
default: T; | ||
default: T & ({} | null); | ||
}; | ||
@@ -87,3 +87,3 @@ protected getJsonSchemaObject(traverser: TreeTraverser): { | ||
anyOf?: undefined; | ||
default: T; | ||
default: T & ({} | null); | ||
examples?: string[] | undefined; | ||
@@ -95,3 +95,3 @@ description?: string | undefined; | ||
anyOf?: undefined; | ||
default: T; | ||
default: T & ({} | null); | ||
examples?: string[] | undefined; | ||
@@ -103,3 +103,3 @@ description?: string | undefined; | ||
anyOf: Omit<any, "type">[]; | ||
default: T; | ||
default: T & ({} | null); | ||
examples?: string[] | undefined; | ||
@@ -111,3 +111,3 @@ description?: string | undefined; | ||
anyOf: Omit<any, "type">[]; | ||
default: T; | ||
default: T & ({} | null); | ||
examples?: string[] | undefined; | ||
@@ -114,0 +114,0 @@ description?: string | undefined; |
{ | ||
"name": "suretype", | ||
"version": "3.0.5", | ||
"version": "3.1.0", | ||
"description": "Typesafe JSON (Schema) validator with magic powers 🧙♂️", | ||
@@ -40,25 +40,28 @@ "author": "Gustaf Räntilä", | ||
], | ||
"workspaces": [ | ||
"webpack" | ||
], | ||
"devDependencies": { | ||
"@babel/preset-env": "^7.15.6", | ||
"@babel/preset-typescript": "^7.15.0", | ||
"@hapi/joi": "^17.1.0", | ||
"@types/benchmark": "^2.1.1", | ||
"@types/hapi__joi": "^17.1.8", | ||
"@types/jest": "^27.4.0", | ||
"@types/node": "^17.0.16", | ||
"@babel/preset-env": "^7.20.2", | ||
"@babel/preset-typescript": "^7.18.6", | ||
"@hapi/joi": "^17.1.1", | ||
"@types/benchmark": "^2.1.2", | ||
"@types/hapi__joi": "^17.1.9", | ||
"@types/jest": "^29.4.0", | ||
"@types/node": "^18.11.18", | ||
"benchmark": "^2.1.4", | ||
"cz-conventional-changelog": "^3.1.0", | ||
"jest": "^27.5.0", | ||
"ow": "^0.23.0", | ||
"rimraf": "^3.0.1", | ||
"superstruct": "^0.15.0", | ||
"tempy": "^1.0.0", | ||
"cz-conventional-changelog": "^3.3.0", | ||
"jest": "^29.4.1", | ||
"ow": "^1.1.1", | ||
"rimraf": "^4.1.2", | ||
"superstruct": "^1.0.3", | ||
"tempy": "^3.0.0", | ||
"ts-jest-resolver": "^2.0.0", | ||
"ts-node": "^10.5.0", | ||
"typescript": "^4.5.5", | ||
"zod": "^1.11.13" | ||
"ts-node": "^10.9.1", | ||
"typescript": "^4.9.5", | ||
"zod": "^3.20.2" | ||
}, | ||
"dependencies": { | ||
"ajv": "^6.11.0", | ||
"awesome-ajv-errors": "^4.1.4", | ||
"awesome-ajv-errors": "^5.0.0", | ||
"meta-types": "^1.1.1" | ||
@@ -70,3 +73,4 @@ }, | ||
} | ||
} | ||
}, | ||
"packageManager": "yarn@3.2.4" | ||
} |
@@ -5,3 +5,2 @@ [![npm version][npm-image]][npm-url] | ||
[![coverage status][coverage-image]][coverage-url] | ||
[![Language grade: JavaScript][lgtm-image]][lgtm-url] | ||
[![Node.JS version][node-version]][node-url] | ||
@@ -439,8 +438,6 @@ | ||
[downloads-image]: https://img.shields.io/npm/dm/suretype.svg | ||
[build-image]: https://img.shields.io/github/workflow/status/grantila/suretype/Master.svg | ||
[build-image]: https://img.shields.io/github/actions/workflow/status/grantila/suretype/master.yml?branch=master | ||
[build-url]: https://github.com/grantila/suretype/actions?query=workflow%3AMaster | ||
[coverage-image]: https://coveralls.io/repos/github/grantila/suretype/badge.svg?branch=master | ||
[coverage-url]: https://coveralls.io/github/grantila/suretype?branch=master | ||
[lgtm-image]: https://img.shields.io/lgtm/grade/javascript/g/grantila/suretype.svg?logo=lgtm&logoWidth=18 | ||
[lgtm-url]: https://lgtm.com/projects/g/grantila/suretype/context:javascript | ||
[node-version]: https://img.shields.io/node/v/suretype | ||
@@ -447,0 +444,0 @@ [node-url]: https://nodejs.org/en/ |
177243
4500
449
+ Addedawesome-ajv-errors@5.1.0(transitive)
+ Addedawesome-code-frame@1.1.0(transitive)
+ Addedchalk@5.4.1(transitive)
+ Addedcharcodes@0.2.0(transitive)
+ Addedjs-tokens@8.0.3(transitive)
+ Addedjson-cst@1.2.0(transitive)
+ Addedjson-lexer@1.2.0(transitive)
+ Addedjsonpos@4.1.2(transitive)
- Removed@babel/code-frame@7.26.2(transitive)
- Removedansi-styles@4.3.0(transitive)
- Removedawesome-ajv-errors@4.1.4(transitive)
- Removedchalk@4.1.2(transitive)
- Removedcode-error-fragment@0.0.230(transitive)
- Removedcolor-convert@2.0.1(transitive)
- Removedcolor-name@1.1.4(transitive)
- Removedgrapheme-splitter@1.0.4(transitive)
- Removedjs-tokens@4.0.0(transitive)
- Removedjson-to-ast@2.1.0(transitive)
- Removedjsonpos@3.2.1(transitive)
- Removedpicocolors@1.1.1(transitive)
Updatedawesome-ajv-errors@^5.0.0