VariantSchema
Accessors
Constructors
Signature
declare function make<Variants extends readonly Array<string>, Default extends string>(options: { readonly defaultVariant: Default; readonly variants: Variants;}): { readonly Class: <Self = never>(identifier: string) => <Fields extends Fields>(fields: Fields & Validate<Fields, Variants[number]>, annotations?: any) => [Self] extends [never] ? "Missing `Self` generic - use `class Self extends Class<Self>()({ ... })`" : ClassFromFields<Self, Fields, ExtractFields<Default, Fields, true>> & { [V in string]: Struct<Simplify<ExtractFields<V, Fields, false>>> }; readonly extract: { <V extends string>(variant: V): <A extends Struct<any>>(self: A) => Extract<V, A, V extends Default ? true : false>; <V extends string, A extends Struct<any>>(self: A, variant: V): Extract<V, A, V extends Default ? true : false>; }; readonly Field: <A extends ConfigWithKeys<Variants[number]>>(config: A & { [K in string | number | symbol]: never }) => Field<A>; readonly fieldEvolve: { <Self extends any, Mapping extends any>(f: Mapping): (self: Self) => Field<Self extends Field<S> ? { [K in string | number | symbol]: K extends keyof Mapping ? Mapping[K] extends (arg: any) => any ? ReturnType<any[any]> : S[K] : S[K] } : { [K in string]: K extends keyof Mapping ? Mapping[K] extends (arg: any) => any ? ReturnType<any[any]> : Self : Self }>; <Self extends any, Mapping extends any>(self: Self, f: Mapping): Field<Self extends Field<S> ? { [K in string | number | symbol]: K extends keyof Mapping ? Mapping[K] extends (arg: any) => any ? ReturnType<any[any]> : S[K] : S[K] } : { [K in string]: K extends keyof Mapping ? Mapping[K] extends (arg: any) => any ? ReturnType<any[any]> : Self : Self }>; }; readonly FieldExcept: <Keys extends readonly Array<Variants[number]>>(...keys: Keys) => <S extends any>(schema: S) => Field<{ [K in string]: S }>; readonly fieldFromKey: { <Self extends any, Mapping extends any>(mapping: Mapping): (self: Self) => Field<Self extends Field<S> ? { [K in string | number | symbol]: K extends keyof Mapping ? Mapping[K] extends string ? Rename<S[K], any[any]> : S[K] : S[K] } : { [K in string]: K extends keyof Mapping ? Mapping[K] extends string ? Rename<Self, any[any]> : Self : Self }>; <Self extends any, Mapping extends any>(self: Self, mapping: Mapping): Field<Self extends Field<S> ? { [K in string | number | symbol]: K extends keyof Mapping ? Mapping[K] extends string ? Rename<S[K], any[any]> : S[K] : S[K] } : { [K in string]: K extends keyof Mapping ? Mapping[K] extends string ? Rename<Self, any[any]> : Self : Self }>; }; readonly FieldOnly: <Keys extends readonly Array<Variants[number]>>(...keys: Keys) => <S extends any>(schema: S) => Field<{ [K in string]: S }>; readonly Struct: <A extends Fields>(fields: A & Validate<A, Variants[number]>) => Struct<A>; readonly Union: <Members extends readonly Array<Struct<any>>>(...members: Members) => Union<Members> & Variants<Members, Variants[number]>;}Extractors
Signature
type Extract<V extends string, A extends Struct<any>, IsDefault = false> = [A] extends [Struct<infer Fields>] ? IsDefault extends true ? [A] extends [Schema.Schema.Any] ? A : Schema.Struct<Schema.Simplify<ExtractFields<V, Fields>>> : Schema.Struct<Schema.Simplify<ExtractFields<V, Fields>>> : neverExtractFields type
Added in v1.0.0
Source
Signature
type ExtractFields<V extends string, Fields extends Struct.Fields, IsDefault = false> = { [K in keyof Fields]: [Fields[K]] extends [Struct<infer _>] ? Extract<V, Fields[K], IsDefault> : [Fields[K]] extends [Field<infer Config>] ? [Config[V]] extends [Schema.Schema.All | Schema.PropertySignature.All] ? Config[V] : never : [Fields[K]] extends [Schema.Schema.All | Schema.PropertySignature.All] ? Fields[K] : never }Guards
Models
Signature
interface Class<Self, Fields extends Struct.Fields, SchemaFields extends Schema.Struct.Fields, A, I, R, C> extends Schema<Self, Schema.Simplify<I>, R>, Struct<Schema.Simplify<Fields>> { constructor(props: RequiredKeys<C> extends never ? any : Simplify<C>, options?: { readonly disableValidation?: boolean; }); readonly ast: Transformation; readonly fields: Simplify<SchemaFields>; readonly identifier: string; annotations(annotations: Schema<Self>): SchemaClass<Self, I, R>; make<Args extends Array<any>, X>(this: (...args: Args) => X, ...args: Args): X;}Signature
interface Field<in out A extends Field.Config> extends Pipeable { readonly [FieldTypeId]: typeof FieldTypeId; readonly schemas: A;}Signature
interface fromKey<S extends Schema.Schema.All, Key extends string> extends PropertySignature<":", Type<S>, Key, ":", Encoded<S>, false, Context<S>> {}Signature
interface Struct<in out A extends Field.Fields> extends Pipeable { readonly [TypeId]: A;}Signature
interface Union<Members extends ReadonlyArray<Struct<any>>> extends Union<{ [K in keyof Members]: [Members[K]] extends [Schema.Schema.All] ? Members[K] : never }> { constructor(_: never);}Overrideable
Signature
declare function Override<A>(value: A): A & Brand<"Override">Overrideable
Added in v1.0.0
Source
Signature
declare const Overrideable: <From, IFrom, RFrom, To, ITo, R>(from: any, to: any, options: { readonly constructorDefault?: () => To; readonly decode?: any; readonly generate: (_: Option<ITo>) => Effect<From, ParseIssue, R>;}) => Overrideable<To, IFrom, RFrom | R>Overrideable interface
Added in v1.0.0
Source
Signature
interface Overrideable<To, From, R = never> extends PropertySignature<":", To & Brand<"Override"> | undefined, never, ":", From, true, R> {}Type Ids
FieldTypeId
Added in v1.0.0
Source
Signature
declare const FieldTypeId: unique symbolFieldTypeId type
Added in v1.0.0
Source
Signature
type FieldTypeId = typeof FieldTypeIdSignature
declare const TypeId: unique symbolSignature
type TypeId = typeof TypeId