Schema
Accessor
Signature
declare function exitSchema<SA, SI, FA, FI, R>(self: WithResult<SA, SI, FA, FI, R>): Schema<Exit<SA, FA>, ExitEncoded<SI, FI, unknown>, R>Signature
declare function failureSchema<SA, SI, FA, FI, R>(self: WithResult<SA, SI, FA, FI, R>): Schema<FA, FI, R>Signature
declare function serializableSchema<A, I, R>(self: Serializable<A, I, R>): Schema<A, I, R>Signature
declare function successSchema<SA, SI, FA, FI, R>(self: WithResult<SA, SI, FA, FI, R>): Schema<SA, SI, R>Annotations
Signature
interface Annotable<Self extends Schema<A, I, R>, A, I = A, R = never> extends Schema<A, I, R> { annotations(annotations: GenericSchema<A>): Self;}AnnotableClass
interfaceSignature
interface AnnotableClass<Self extends Schema<A, I, R>, A, I = A, R = never> extends Annotable<Self, A, I, R> { constructor(_: never);}Merges a set of new annotations with existing ones, potentially overwriting any duplicates.
Signature
declare const annotations: { <S extends All>(annotations: GenericSchema<Type<S>>): (self: S) => ReturnType<S["annotations"]>; <S extends All>(self: S, annotations: GenericSchema<Type<S>>): ReturnType<S["annotations"]>;}Api Interface
AnnotableDeclare
interfaceSignature
interface AnnotableDeclare<Self extends declare<A, I, P, R>, A, I = A, P extends ReadonlyArray<Schema.All> = readonly [], R = Schema.Context<P[number]>> extends declare<A, I, P, R> { constructor(_: never); annotations(annotations: Schema<A>): Self;}Signature
interface Array$<Value extends Schema.Any> extends TupleType<[], [Value]> { constructor(_: never); readonly value: Value; annotations(annotations: Schema<readonly Array<Type<Value>>>): Array$<Value>;}ArrayEnsure
interfaceSignature
interface ArrayEnsure<Value extends Schema.Any> extends transform<Union<[Value, Array$<Value>]>, Array$<SchemaClass<Schema.Type<Value>>>> { constructor(_: never);}Signature
interface brand<S extends Schema.Any, B extends string | symbol> extends BrandSchema<Schema.Type<S> & Brand<B>, Schema.Encoded<S>, Schema.Context<S>> { constructor(_: never); readonly from: S; annotations(annotations: Schema<Type<S> & Brand<B>>): brand<S, B>;}Signature
interface Cause<E extends Schema.All, D extends Schema.All> extends transform<SchemaClass<CauseEncoded<Schema.Type<E>, Schema.Type<Defect>>, CauseEncoded<Schema.Encoded<E>, Schema.Encoded<Defect>>, Schema.Context<E> | Schema.Context<D>>, CauseFromSelf<SchemaClass<Schema.Type<E>>, SchemaClass<Schema.Type<D>>>> { constructor(_: never);}CauseFromSelf
interfaceSignature
interface CauseFromSelf<E extends Schema.All, D extends Schema.All> extends AnnotableDeclare<CauseFromSelf<E, D>, cause_.Cause<Schema.Type<E>>, cause_.Cause<Schema.Encoded<E>>, [E, D]> { constructor(_: never);}Signature
interface Chunk<Value extends Schema.Any> extends transform<Array$<Value>, ChunkFromSelf<SchemaClass<Schema.Type<Value>>>> { constructor(_: never);}ChunkFromSelf
interfaceSignature
interface ChunkFromSelf<Value extends Schema.Any> extends AnnotableDeclare<ChunkFromSelf<Value>, chunk_.Chunk<Schema.Type<Value>>, chunk_.Chunk<Schema.Encoded<Value>>, [Value]> { constructor(_: never);}Signature
interface Class<Self, Fields extends Struct.Fields, I, R, C, Inherited, Proto> extends Schema<Self, Simplify<I>, R> { constructor(props: RequiredKeys<C> extends never ? void | { [K in string | number | symbol]: C[K] } : { [K in string | number | symbol]: C[K] }, options?: MakeOptions); readonly ast: Transformation; readonly fields: { [K in string | number | symbol]: Fields[K] }; readonly identifier: string; annotations(annotations: Schema<Self>): SchemaClass<Self, { [K in string | number | symbol]: I[K] }, R>; extend<Extended = never>(identifier: string): <NewFields extends Fields>(fields: NewFields | HasFields<NewFields>, annotations?: ClassAnnotations<Extended, { [K in string | number | symbol]: Type<Fields & NewFields>[K] }>) => [Extended] extends [never] ? "Missing `Self` generic - use `class Self extends Base.extend<Self>()({ ... })`" : Class<Extended, Fields & NewFields, I & { [K in string | number | symbol]: Encoded<NewFields[K]> } & { [K in string | number | symbol]: Encoded<NewFields[K]> }, R | Context<NewFields[keyof NewFields]>, C & Constructor<NewFields>, Self, Proto>; make<C extends (...args: Array<any>) => any>(this: C, ...args: ConstructorParameters<C>): InstanceType<C>; transformOrFail<Transformed = never>(identifier: string): <NewFields extends Fields, R2, R3>(fields: NewFields, options: { readonly decode: (input: { [K in string | number | symbol]: Type<Fields>[K] }, options: ParseOptions, ast: Transformation) => Effect<{ [K in string | number | symbol]: Type<Fields & NewFields>[K] }, ParseIssue, R2>; readonly encode: (input: { [K in string | number | symbol]: Type<Fields & NewFields>[K] }, options: ParseOptions, ast: Transformation) => Effect<Type<Fields>, ParseIssue, R3>; }, annotations?: ClassAnnotations<Transformed, { [K in string | number | symbol]: Type<Fields & NewFields>[K] }>) => [Transformed] extends [never] ? "Missing `Self` generic - use `class Self extends Base.transformOrFail<Self>()({ ... })`" : Class<Transformed, Fields & NewFields, I, R | R2 | R3 | Context<NewFields[keyof NewFields]>, C & Constructor<NewFields>, Self, Proto>; transformOrFailFrom<Transformed = never>(identifier: string): <NewFields extends Fields, R2, R3>(fields: NewFields, options: { readonly decode: (input: { [K in string | number | symbol]: I[K] }, options: ParseOptions, ast: Transformation) => Effect<{ [K in string | number | symbol]: I & { [K in string | number | symbol]: Encoded<NewFields[K]> } & { [K in string | number | symbol]: Encoded<...[...]> }[K] }, ParseIssue, R2>; readonly encode: (input: { [K in string | number | symbol]: I & { [K in string | number | symbol]: Encoded<NewFields[K]> } & { [K in string | number | symbol]: Encoded<NewFields[K]> }[K] }, options: ParseOptions, ast: Transformation) => Effect<I, ParseIssue, R3>; }, annotations?: ClassAnnotations<Transformed, { [K in string | number | symbol]: Type<Fields & NewFields>[K] }>) => [Transformed] extends [never] ? "Missing `Self` generic - use `class Self extends Base.transformOrFailFrom<Self>()({ ... })`" : Class<Transformed, Fields & NewFields, I, R | R2 | R3 | Context<NewFields[keyof NewFields]>, C & Constructor<NewFields>, Self, Proto>;}Signature
interface Data<Value extends Schema.Any> extends transform<Value, DataFromSelf<SchemaClass<Schema.Type<Value>>>> { constructor(_: never);}DataFromSelf
interfaceSignature
interface DataFromSelf<Value extends Schema.Any> extends AnnotableDeclare<DataFromSelf<Value>, Schema.Type<Value>, Schema.Encoded<Value>, [Value]> { constructor(_: never);}Signature
interface declare<A, I = A, P extends ReadonlyArray<Schema.All> = readonly [], R = Schema.Context<P[number]>> extends AnnotableClass<declare<A, I, P, R>, A, I, R> { constructor(_: never); readonly typeParameters: Readonly<P>;}Signature
interface Either<Right extends Schema.All, Left extends Schema.All> extends transform<Union<[Struct<{ _tag: Literal<["Right"]>; right: Right;}>, Struct<{ _tag: Literal<["Left"]>; left: Left;}>]>, EitherFromSelf<SchemaClass<Schema.Type<Right>>, SchemaClass<Schema.Type<Left>>>> { constructor(_: never);}EitherFromSelf
interfaceSignature
interface EitherFromSelf<R extends Schema.All, L extends Schema.All> extends AnnotableDeclare<EitherFromSelf<R, L>, either_.Either<Schema.Type<R>, Schema.Type<L>>, either_.Either<Schema.Encoded<R>, Schema.Encoded<L>>, [R, L]> { constructor(_: never);}EitherFromUnion
interfaceSignature
interface EitherFromUnion<Right extends Schema.All, Left extends Schema.All> extends transform<Union<[transform<Right, Struct<{ _tag: Literal<["Right"]>; right: SchemaClass<Schema.Type<Right>>;}>>, transform<Left, Struct<{ _tag: Literal<["Left"]>; right: SchemaClass<Schema.Type<Left>>;}>>]>, EitherFromSelf<SchemaClass<Schema.Type<Right>>, SchemaClass<Schema.Type<Left>>>> { constructor(_: never);}Signature
interface Enums<A extends EnumsDefinition> extends AnnotableClass<Enums<A>, A[keyof A]> { constructor(_: never); readonly enums: A;}Signature
interface Exit<A extends Schema.All, E extends Schema.All, D extends Schema.All> extends transform<Union<[Struct<{ _tag: Literal<["Failure"]>; cause: SchemaClass<CauseEncoded<Schema.Type<E>, Schema.Type<D>>, CauseEncoded<Schema.Encoded<E>, Schema.Encoded<D>>, Schema.Context<E> | Schema.Context<D>>;}>, Struct<{ _tag: Literal<["Success"]>; value: A;}>]>, ExitFromSelf<SchemaClass<Schema.Type<A>>, SchemaClass<Schema.Type<E>>, SchemaClass<Schema.Type<D>>>> { constructor(_: never);}ExitFromSelf
interfaceSignature
interface ExitFromSelf<A extends Schema.All, E extends Schema.All, D extends Schema.All> extends AnnotableDeclare<ExitFromSelf<A, E, D>, exit_.Exit<Schema.Type<A>, Schema.Type<E>>, exit_.Exit<Schema.Encoded<A>, Schema.Encoded<E>>, [A, E, D]> { constructor(_: never);}Signature
interface extend<Self extends Schema.Any, That extends Schema.Any> extends AnnotableClass<extend<Self, That>, Schema.Type<Self> & Schema.Type<That>, Schema.Encoded<Self> & Schema.Encoded<That>, Schema.Context<Self> | Schema.Context<That>> { constructor(_: never);}Signature
interface filter<From extends Schema.Any> extends refine<Schema.Type<From>, From> { constructor(_: never);}filterEffect
interfaceSignature
interface filterEffect<S extends Schema.Any, FD = never> extends transformOrFail<S, SchemaClass<Schema.Type<S>>, FD> { constructor(_: never);}Signature
interface HashMap<K extends Schema.Any, V extends Schema.Any> extends transform<Array$<Tuple2<K, V>>, HashMapFromSelf<SchemaClass<Schema.Type<K>>, SchemaClass<Schema.Type<V>>>> { constructor(_: never);}HashMapFromSelf
interfaceSignature
interface HashMapFromSelf<K extends Schema.Any, V extends Schema.Any> extends AnnotableDeclare<HashMapFromSelf<K, V>, hashMap_.HashMap<Schema.Type<K>, Schema.Type<V>>, hashMap_.HashMap<Schema.Encoded<K>, Schema.Encoded<V>>, [K, V]> { constructor(_: never);}Signature
interface HashSet<Value extends Schema.Any> extends transform<Array$<Value>, HashSetFromSelf<SchemaClass<Schema.Type<Value>>>> { constructor(_: never);}HashSetFromSelf
interfaceSignature
interface HashSetFromSelf<Value extends Schema.Any> extends AnnotableDeclare<HashSetFromSelf<Value>, hashSet_.HashSet<Schema.Type<Value>>, hashSet_.HashSet<Schema.Encoded<Value>>, [Value]> { constructor(_: never);}instanceOf
interfaceSignature
interface instanceOf<A> extends AnnotableDeclare<instanceOf<A>, A> { constructor(_: never);}Signature
interface List<Value extends Schema.Any> extends transform<Array$<Value>, ListFromSelf<SchemaClass<Schema.Type<Value>>>> { constructor(_: never);}ListFromSelf
interfaceSignature
interface ListFromSelf<Value extends Schema.Any> extends AnnotableDeclare<ListFromSelf<Value>, list_.List<Schema.Type<Value>>, list_.List<Schema.Encoded<Value>>, [Value]> { constructor(_: never);}Signature
interface Literal<Literals extends array_.NonEmptyReadonlyArray<AST.LiteralValue>> extends AnnotableClass<Literal<Literals>, Literals[number]> { constructor(_: never); readonly literals: Readonly<Literals>;}Signature
interface Map$<K extends Schema.Any, V extends Schema.Any> extends transform<Array$<Tuple2<K, V>>, MapFromSelf<SchemaClass<Schema.Type<K>>, SchemaClass<Schema.Type<V>>>> { constructor(_: never);}MapFromSelf
interfaceSignature
interface MapFromSelf<K extends Schema.Any, V extends Schema.Any> extends AnnotableDeclare<MapFromSelf<K, V>, Map<Schema.Type<K>, Schema.Type<V>>, ReadonlyMap<Schema.Encoded<K>, Schema.Encoded<V>>, [K, V]> { constructor(_: never);}Signature
interface mutable<S extends Schema.Any> extends AnnotableClass<mutable<S>, SimplifyMutable<Schema.Type<S>>, SimplifyMutable<Schema.Encoded<S>>, Schema.Context<S>> { constructor(_: never);}NonEmptyArray
interfaceSignature
interface NonEmptyArray<Value extends Schema.Any> extends AnnotableClass<NonEmptyArray<Value>, array_.NonEmptyReadonlyArray<Schema.Type<Value>>, array_.NonEmptyReadonlyArray<Schema.Encoded<Value>>, Schema.Context<Value>> { constructor(_: never); readonly elements: readonly [Value]; readonly rest: readonly [Value]; readonly value: Value;}NonEmptyArrayEnsure
interfaceSignature
interface NonEmptyArrayEnsure<Value extends Schema.Any> extends transform<Union<[Value, NonEmptyArray<Value>]>, NonEmptyArray<SchemaClass<Schema.Type<Value>>>> { constructor(_: never);}NonEmptyChunk
interfaceSignature
interface NonEmptyChunk<Value extends Schema.Any> extends transform<NonEmptyArray<Value>, NonEmptyChunkFromSelf<SchemaClass<Schema.Type<Value>>>> { constructor(_: never);}NonEmptyChunkFromSelf
interfaceSignature
interface NonEmptyChunkFromSelf<Value extends Schema.Any> extends AnnotableDeclare<NonEmptyChunkFromSelf<Value>, chunk_.NonEmptyChunk<Schema.Type<Value>>, chunk_.NonEmptyChunk<Schema.Encoded<Value>>, [Value]> { constructor(_: never);}Signature
interface NullishOr<S extends Schema.All> extends Union<[S, typeof Null, typeof Undefined]> { constructor(_: never); annotations(annotations: Schema<Type<S> | null | undefined>): NullishOr<S>;}Signature
interface NullOr<S extends Schema.All> extends Union<[S, typeof Null]> { constructor(_: never); annotations(annotations: Schema<Type<S> | null>): NullOr<S>;}Signature
interface Option<Value extends Schema.Any> extends transform<Union<[Struct<{ _tag: Literal<["None"]>;}>, Struct<{ _tag: Literal<["Some"]>; value: Value;}>]>, OptionFromSelf<SchemaClass<Schema.Type<Value>>>> { constructor(_: never);}Signature
interface optional<S extends Schema.All> extends PropertySignature<"?:", Schema.Type<S> | undefined, never, "?:", Schema.Encoded<S> | undefined, false, Schema.Context<S>> { readonly from: S; annotations(annotations: Annotations<Type<S> | undefined>): optional<S>;}optionalWith
interfaceSignature
interface optionalWith<S extends Schema.All, Options> extends PropertySignature<Types.Has<Options, "as" | "default"> extends true ? ":" : "?:", Types.Has<Options, "as"> extends true ? option_.Option<Schema.Type<S>> : Schema.Type<S> | Types.Has<Options, "as" | "default" | "exact"> extends true ? never : undefined, never, "?:", Schema.Encoded<S> | Types.Has<Options, "nullable"> extends true ? null : never | Types.Has<Options, "exact"> extends true ? never : undefined, Types.Has<Options, "default">, Schema.Context<S>> { readonly from: S; annotations(annotations: Annotations<Has<Options, "as"> extends true ? Option<Type<S>> : Type<S> | Has<Options, "default" | "as" | "exact"> extends true ? never : undefined>): optionalWith<S, Options>;}OptionFromNullishOr
interfaceSignature
interface OptionFromNullishOr<Value extends Schema.Any> extends transform<NullishOr<Value>, OptionFromSelf<SchemaClass<Schema.Type<Value>>>> { constructor(_: never);}OptionFromNullOr
interfaceSignature
interface OptionFromNullOr<Value extends Schema.Any> extends transform<NullOr<Value>, OptionFromSelf<SchemaClass<Schema.Type<Value>>>> { constructor(_: never);}OptionFromSelf
interfaceSignature
interface OptionFromSelf<Value extends Schema.Any> extends AnnotableDeclare<OptionFromSelf<Value>, option_.Option<Schema.Type<Value>>, option_.Option<Schema.Encoded<Value>>, [Value]> { constructor(_: never);}OptionFromUndefinedOr
interfaceSignature
interface OptionFromUndefinedOr<Value extends Schema.Any> extends transform<UndefinedOr<Value>, OptionFromSelf<SchemaClass<Schema.Type<Value>>>> { constructor(_: never);}ReadonlyMap$
interfaceSignature
interface ReadonlyMap$<K extends Schema.Any, V extends Schema.Any> extends transform<Array$<Tuple2<K, V>>, ReadonlyMapFromSelf<SchemaClass<Schema.Type<K>>, SchemaClass<Schema.Type<V>>>> { constructor(_: never);}ReadonlyMapFromSelf
interfaceSignature
interface ReadonlyMapFromSelf<K extends Schema.Any, V extends Schema.Any> extends AnnotableDeclare<ReadonlyMapFromSelf<K, V>, ReadonlyMap<Schema.Type<K>, Schema.Type<V>>, ReadonlyMap<Schema.Encoded<K>, Schema.Encoded<V>>, [K, V]> { constructor(_: never);}ReadonlySet$
interfaceSignature
interface ReadonlySet$<Value extends Schema.Any> extends transform<Array$<Value>, ReadonlySetFromSelf<SchemaClass<Schema.Type<Value>>>> { constructor(_: never);}ReadonlySetFromSelf
interfaceSignature
interface ReadonlySetFromSelf<Value extends Schema.Any> extends AnnotableDeclare<ReadonlySetFromSelf<Value>, ReadonlySet<Schema.Type<Value>>, ReadonlySet<Schema.Encoded<Value>>, [Value]> { constructor(_: never);}Signature
interface Record$<K extends Schema.All, V extends Schema.All> extends AnnotableClass<Record$<K, V>, { [P in Schema.Type<K>]: Schema.Type<V> }, { [P in Schema.Encoded<K>]: Schema.Encoded<V> }, Schema.Context<K> | Schema.Context<V>> { constructor(_: never); readonly fields: {}; readonly key: K; readonly records: readonly [{ readonly key: K; readonly value: V; }]; readonly value: V; annotations(annotations: Schema<{ [P in any]: Type<V> }>): Record$<K, V>; make(props: void | { [P in any]: Type<V> }, options?: MakeOptions): { [P in any]: Type<V> };}Signature
interface Redacted<Value extends Schema.Any> extends transform<Value, RedactedFromSelf<SchemaClass<Schema.Type<Value>>>> { constructor(_: never);}RedactedFromSelf
interfaceSignature
interface RedactedFromSelf<Value extends Schema.Any> extends AnnotableDeclare<RedactedFromSelf<Value>, redacted_.Redacted<Schema.Type<Value>>, redacted_.Redacted<Schema.Encoded<Value>>, [Value]> { constructor(_: never);}Signature
interface refine<A, From extends Schema.Any> extends AnnotableClass<refine<A, From>, A, Schema.Encoded<From>, Schema.Context<From>> { constructor(_: never); readonly [RefineSchemaId]: From; readonly filter: (a: Type<From>, options: ParseOptions, self: Refinement) => Option<ParseIssue>; readonly from: From; make(a: Type<From>, options?: MakeOptions): A;}Signature
interface Set$<Value extends Schema.Any> extends transform<Array$<Value>, SetFromSelf<SchemaClass<Schema.Type<Value>>>> { constructor(_: never);}SetFromSelf
interfaceSignature
interface SetFromSelf<Value extends Schema.Any> extends AnnotableDeclare<SetFromSelf<Value>, Set<Schema.Type<Value>>, ReadonlySet<Schema.Encoded<Value>>, [Value]> { constructor(_: never);}Signature
interface SortedSet<Value extends Schema.Any> extends transform<Array$<Value>, SortedSetFromSelf<SchemaClass<Schema.Type<Value>>>> { constructor(_: never);}SortedSetFromSelf
interfaceSignature
interface SortedSetFromSelf<Value extends Schema.Any> extends AnnotableDeclare<SortedSetFromSelf<Value>, sortedSet_.SortedSet<Schema.Type<Value>>, sortedSet_.SortedSet<Schema.Encoded<Value>>, [Value]> { constructor(_: never);}Signature
interface Struct<Fields extends Struct.Fields> extends AnnotableClass<Struct<Fields>, Simplify<Struct.Type<Fields>>, Simplify<Struct.Encoded<Fields>>, Struct.Context<Fields>> { constructor(_: never); readonly fields: Readonly<Fields>; readonly records: readonly []; annotations(annotations: Schema<{ [K in string | number | symbol]: Type<Fields>[K] }>): Struct<Fields>; make(props: RequiredKeys<Constructor<Fields>> extends never ? void | { [K in string | number | symbol]: Constructor<Fields>[K] } : { [K in string | number | symbol]: Constructor<Fields>[K] }, options?: MakeOptions): { [K in string | number | symbol]: Type<Fields>[K] }; omit<Keys extends readonly Array<keyof Fields>>(...keys: Keys): Struct<{ [K in string | number | symbol]: Omit<Fields, Keys[number]>[K] }>; pick<Keys extends readonly Array<keyof Fields>>(...keys: Keys): Struct<{ [K in string | number | symbol]: Pick<Fields, Keys[number]>[K] }>;}Signature
interface suspend<A, I, R> extends AnnotableClass<suspend<A, I, R>, A, I, R> { constructor(_: never);}Signature
interface tag<Tag extends AST.LiteralValue> extends PropertySignature<":", Tag, never, ":", Tag, true, never> {}TaggedClass
interfaceSignature
interface TaggedClass<Self, Tag extends string, Fields extends Struct.Fields> extends Class<Self, Fields, Struct.Encoded<Fields>, Struct.Context<Fields>, Struct.Constructor<Omit<Fields, "_tag">>, {}, {}> { constructor(props: RequiredKeys<Constructor<Omit<Fields, "_tag">>> extends never ? void | { [K in string | number | symbol]: Constructor<Omit<Fields, "_tag">>[K] } : { [K in string | number | symbol]: Constructor<Omit<Fields, "_tag">>[K] }, options?: MakeOptions); readonly _tag: Tag;}TaggedErrorClass
interfaceSignature
interface TaggedErrorClass<Self, Tag extends string, Fields extends Struct.Fields> extends Class<Self, Fields, Struct.Encoded<Fields>, Struct.Context<Fields>, Struct.Constructor<Omit<Fields, "_tag">>, {}, cause_.YieldableError> { constructor(props: RequiredKeys<Constructor<Omit<Fields, "_tag">>> extends never ? void | { [K in string | number | symbol]: Constructor<Omit<Fields, "_tag">>[K] } : { [K in string | number | symbol]: Constructor<Omit<Fields, "_tag">>[K] }, options?: MakeOptions); readonly _tag: Tag;}TaggedRequestClass
interfaceSignature
interface TaggedRequestClass<Self, Tag extends string, Payload extends Struct.Fields, Success extends Schema.All, Failure extends Schema.All> extends Class<Self, Payload, Struct.Encoded<Payload>, Struct.Context<Payload>, Struct.Constructor<Omit<Payload, "_tag">>, TaggedRequest<Tag, Self, Struct.Encoded<Payload>, Struct.Context<Payload>, Schema.Type<Success>, Schema.Encoded<Success>, Schema.Type<Failure>, Schema.Encoded<Failure>, Schema.Context<Success> | Schema.Context<Failure>>, {}> { constructor(props: RequiredKeys<Constructor<Omit<Payload, "_tag">>> extends never ? void | { [K in string | number | symbol]: Constructor<Omit<Payload, "_tag">>[K] } : { [K in string | number | symbol]: Constructor<Omit<Payload, "_tag">>[K] }, options?: MakeOptions); readonly _tag: Tag; readonly failure: Failure; readonly success: Success;}TaggedStruct
typeSignature
type TaggedStruct<Tag extends AST.LiteralValue, Fields extends Struct.Fields> = Struct<{ _tag: tag<Tag>;} & Fields>Signature
interface transform<From extends Schema.All, To extends Schema.All> extends transformOrFail<From, To> { constructor(_: never); annotations(annotations: Schema<Type<To>>): transform<From, To>;}transformLiteral
interfaceSignature
interface transformLiteral<Type extends AST.LiteralValue, Encoded extends AST.LiteralValue> extends transform<Literal<[Encoded]>, Literal<[Type]>> { constructor(_: never); annotations(annotations: Schema<Type>): transformLiteral<Type, Encoded>;}transformOrFail
interfaceSignature
interface transformOrFail<From extends Schema.All, To extends Schema.All, R = never> extends AnnotableClass<transformOrFail<From, To, R>, Schema.Type<To>, Schema.Encoded<From>, Schema.Context<From> | Schema.Context<To> | R> { constructor(_: never); readonly from: From; readonly to: To;}Signature
interface Tuple<Elements extends TupleType.Elements> extends TupleType<Elements, []> { constructor(_: never); annotations(annotations: Schema<ElementsType<Elements, readonly []>>): Tuple<Elements>;}Signature
interface Tuple2<Fst extends Schema.Any, Snd extends Schema.Any> extends AnnotableClass<Tuple2<Fst, Snd>, readonly [Schema.Type<Fst>, Schema.Type<Snd>], readonly [Schema.Encoded<Fst>, Schema.Encoded<Snd>], Schema.Context<Fst> | Schema.Context<Snd>> { constructor(_: never); readonly elements: readonly [Fst, Snd]; readonly rest: readonly [];}Signature
interface TupleType<Elements extends TupleType.Elements, Rest extends TupleType.Rest> extends AnnotableClass<TupleType<Elements, Rest>, TupleType.Type<Elements, Rest>, TupleType.Encoded<Elements, Rest>, Schema.Context<Elements[number]> | Schema.Context<Rest[number]>> { constructor(_: never); readonly elements: Readonly<Elements>; readonly rest: Readonly<Rest>;}TypeLiteral
interfaceSignature
interface TypeLiteral<Fields extends Struct.Fields, Records extends IndexSignature.Records> extends AnnotableClass<TypeLiteral<Fields, Records>, Simplify<TypeLiteral.Type<Fields, Records>>, Simplify<TypeLiteral.Encoded<Fields, Records>>, Struct.Context<Fields> | IndexSignature.Context<Records>> { constructor(_: never); readonly fields: Readonly<Fields>; readonly records: Readonly<Records>; annotations(annotations: Schema<{ [K in string | number | symbol]: Type<Fields, Records>[K] }>): TypeLiteral<Fields, Records>; make(props: RequiredKeys<Constructor<Fields, Records>> extends never ? void | { [K in string | number | symbol]: Constructor<Fields, Records>[K] } : { [K in string | number | symbol]: Constructor<Fields, Records>[K] }, options?: MakeOptions): { [K in string | number | symbol]: Type<Fields, Records>[K] };}UndefinedOr
interfaceSignature
interface UndefinedOr<S extends Schema.All> extends Union<[S, typeof Undefined]> { constructor(_: never); annotations(annotations: Schema<Type<S> | undefined>): UndefinedOr<S>;}Signature
interface Union<Members extends ReadonlyArray<Schema.All>> extends AnnotableClass<Union<Members>, Schema.Type<Members[number]>, Schema.Encoded<Members[number]>, Schema.Context<Members[number]>> { constructor(_: never); readonly members: Readonly<Members>;}API Interface
Signature
interface Element<S extends Schema.Any, Token extends Element.Token> extends Variance<Schema.Type<S>, Schema.Encoded<S>, Schema.Context<S>> { readonly _Token: Token; readonly ast: OptionalType; readonly from: S; annotations(annotations: Annotations<Type<S>>): Element<S, Token>;}propertySignature
interfaceSignature
interface propertySignature<S extends Schema.All> extends PropertySignature<":", Schema.Type<S>, never, ":", Schema.Encoded<S>, false, Schema.Context<S>> { readonly from: S; annotations(annotations: Annotations<Type<S>>): propertySignature<S>;}TemplateLiteral
interfaceSignature
interface TemplateLiteral<A> extends SchemaClass<A> { constructor(_: never);}TemplateLiteralParser
interfaceSignature
interface TemplateLiteralParser<Params extends array_.NonEmptyReadonlyArray<TemplateLiteralParserParameters>> extends Schema<GetTemplateLiteralParserType<Params>, GetTemplateLiteralParserEncoded<Params>, Schema.Context<Params[number]>> { readonly params: Params;}ArrayFormatter
Signature
declare class ArrayFormatterIssue extends Variance<{ readonly _tag: "Composite" | "Pointer" | "Unexpected" | "Missing" | "Refinement" | "Transformation" | "Type" | "Forbidden"; readonly message: string; readonly path: readonly Array<string | number | symbol>;}, { _tag: "Composite" | "Pointer" | "Unexpected" | "Missing" | "Refinement" | "Transformation" | "Type" | "Forbidden"; message: string; path: readonly Array<string | number | { _tag: "symbol"; key: string; }>;}, never, this> { constructor(_: never);}BigDecimal Constructors
Signature
declare class BigDecimalFromSelf extends Variance<BigDecimal, BigDecimal, never, this> { constructor(_: never);}Signature
declare const NegativeBigDecimalFromSelf: filter<Schema<bigDecimal_.BigDecimal>>Signature
declare const NonNegativeBigDecimalFromSelf: filter<Schema<bigDecimal_.BigDecimal>>Signature
declare const NonPositiveBigDecimalFromSelf: filter<Schema<bigDecimal_.BigDecimal>>Signature
declare const PositiveBigDecimalFromSelf: filter<Schema<bigDecimal_.BigDecimal>>BigDecimal Filters
Signature
declare function betweenBigDecimal<S extends Any>(minimum: BigDecimal, maximum: BigDecimal, annotations?: Filter<Type<S>, Type<S>>): <A extends BigDecimal>(self: S & Schema<A, Encoded<S>, Context<S>>) => filter<S>Signature
declare function greaterThanBigDecimal<S extends Any>(min: BigDecimal, annotations?: Filter<Type<S>, Type<S>>): <A extends BigDecimal>(self: S & Schema<A, Encoded<S>, Context<S>>) => filter<S>Signature
declare function greaterThanOrEqualToBigDecimal<S extends Any>(min: BigDecimal, annotations?: Filter<Type<S>, Type<S>>): <A extends BigDecimal>(self: S & Schema<A, Encoded<S>, Context<S>>) => filter<S>Signature
declare function lessThanBigDecimal<S extends Any>(max: BigDecimal, annotations?: Filter<Type<S>, Type<S>>): <A extends BigDecimal>(self: S & Schema<A, Encoded<S>, Context<S>>) => filter<S>Signature
declare function lessThanOrEqualToBigDecimal<S extends Any>(max: BigDecimal, annotations?: Filter<Type<S>, Type<S>>): <A extends BigDecimal>(self: S & Schema<A, Encoded<S>, Context<S>>) => filter<S>Signature
declare function negativeBigDecimal<S extends Any>(annotations?: Filter<Type<S>, Type<S>>): <A extends BigDecimal>(self: S & Schema<A, Encoded<S>, Context<S>>) => filter<S>Signature
declare function nonNegativeBigDecimal<S extends Any>(annotations?: Filter<Type<S>, Type<S>>): <A extends BigDecimal>(self: S & Schema<A, Encoded<S>, Context<S>>) => filter<S>Signature
declare function nonPositiveBigDecimal<S extends Any>(annotations?: Filter<Type<S>, Type<S>>): <A extends BigDecimal>(self: S & Schema<A, Encoded<S>, Context<S>>) => filter<S>Signature
declare function positiveBigDecimal<S extends Any>(annotations?: Filter<Type<S>, Type<S>>): <A extends BigDecimal>(self: S & Schema<A, Encoded<S>, Context<S>>) => filter<S>BigDecimal Transformations
Signature
declare class BigDecimal extends Variance<BigDecimal, string, never, this> { constructor(_: never);}A schema that transforms a number into a BigDecimal.
When encoding, this Schema will produce incorrect results if the BigDecimal exceeds the 64-bit range of a number.
Signature
declare class BigDecimalFromNumber extends Variance<BigDecimal, number, never, this> { constructor(_: never);}Clamps a BigDecimal between a minimum and a maximum value.
Signature
declare function clampBigDecimal(minimum: BigDecimal, maximum: BigDecimal): <S extends Any, A extends BigDecimal>(self: S & Schema<A, Encoded<S>, Context<S>>) => transform<S, filter<SchemaClass<A, A, never>>>Bigint Constructors
Signature
declare const NegativeBigInt: filter<Schema<bigint, string>>Signature
declare const NegativeBigIntFromSelf: filter<Schema<bigint>>Signature
declare const NonNegativeBigInt: filter<Schema<bigint, string>>Signature
declare const NonNegativeBigIntFromSelf: filter<Schema<bigint>>Signature
declare const NonPositiveBigInt: filter<Schema<bigint, string>>Signature
declare const NonPositiveBigIntFromSelf: filter<Schema<bigint>>Signature
declare const PositiveBigInt: filter<Schema<bigint, string>>Signature
declare const PositiveBigIntFromSelf: filter<Schema<bigint>>Bigint Filters
Signature
declare function betweenBigInt<S extends Any>(min: bigint, max: bigint, annotations?: Filter<Type<S>, Type<S>>): <A extends bigint>(self: S & Schema<A, Encoded<S>, Context<S>>) => filter<S>Signature
declare function greaterThanBigInt<S extends Any>(min: bigint, annotations?: Filter<Type<S>, Type<S>>): <A extends bigint>(self: S & Schema<A, Encoded<S>, Context<S>>) => filter<S>Signature
declare function greaterThanOrEqualToBigInt<S extends Any>(min: bigint, annotations?: Filter<Type<S>, Type<S>>): <A extends bigint>(self: S & Schema<A, Encoded<S>, Context<S>>) => filter<S>Signature
declare function lessThanBigInt<S extends Any>(max: bigint, annotations?: Filter<Type<S>, Type<S>>): <A extends bigint>(self: S & Schema<A, Encoded<S>, Context<S>>) => filter<S>Signature
declare function lessThanOrEqualToBigInt<S extends Any>(max: bigint, annotations?: Filter<Type<S>, Type<S>>): <A extends bigint>(self: S & Schema<A, Encoded<S>, Context<S>>) => filter<S>Signature
declare function negativeBigInt<S extends Any>(annotations?: Filter<Type<S>, Type<S>>): <A extends bigint>(self: S & Schema<A, Encoded<S>, Context<S>>) => filter<S>Signature
declare function nonNegativeBigInt<S extends Any>(annotations?: Filter<Type<S>, Type<S>>): <A extends bigint>(self: S & Schema<A, Encoded<S>, Context<S>>) => filter<S>Signature
declare function nonPositiveBigInt<S extends Any>(annotations?: Filter<Type<S>, Type<S>>): <A extends bigint>(self: S & Schema<A, Encoded<S>, Context<S>>) => filter<S>Signature
declare function positiveBigInt<S extends Any>(annotations?: Filter<Type<S>, Type<S>>): <A extends bigint>(self: S & Schema<A, Encoded<S>, Context<S>>) => filter<S>Bigint Transformations
This schema transforms a number into a bigint by parsing the number using the BigInt function.
It returns an error if the value can't be safely encoded as a number due to being out of range.
Signature
declare class BigIntFromNumber extends Variance<bigint, number, never, this> { constructor(_: never);}Clamps a bigint between a minimum and a maximum value.
Signature
declare function clampBigInt(minimum: bigint, maximum: bigint): <S extends Any, A extends bigint>(self: S & Schema<A, Encoded<S>, Context<S>>) => transform<S, filter<SchemaClass<A, A, never>>>Boolean Constructors
Converts an arbitrary value to a boolean by testing whether it is truthy.
Uses !!val to coerce the value to a boolean.
Signature
declare class BooleanFromUnknown extends Variance<boolean, unknown, never, this> { constructor(_: never);}Boolean Transformations
Converts an string value into its corresponding boolean
("true" as true and "false" as false).
Signature
declare class BooleanFromString extends Variance<boolean, "true" | "false", never, this> { constructor(_: never);}Signature
declare class Not extends Variance<boolean, boolean, never, this> { constructor(_: never);}Branding
Returns a nominal branded schema by applying a brand to a given schema.
Signature
declare const brand: <S extends Any, B extends string | symbol>(brand: B, annotations?: Schema<Type<S> & Brand<B>, readonly []>) => (self: S) => brand<S, B>Example
Schema<A> + B -> Schema<A & Brand<B>>Example
import * as Schema from "effect/Schema"
const Int = Schema.Number.pipe(Schema.int(), Schema.brand("Int"))type Int = Schema.Schema.Type<typeof Int> // number & Brand<"Int">BrandSchema
interfaceSignature
interface BrandSchema<A extends Brand<any>, I = A, R = never> extends AnnotableClass<BrandSchema<A, I, R>, A, I, R> { constructor(_: never); make(a: Unbranded<A>, options?: MakeOptions): A;}Cause Transformations
Signature
declare const Cause: <E extends All, D extends All>(__namedParameters: { readonly defect: D; readonly error: E;}) => Cause<E, D>Signature
declare const CauseFromSelf: <E extends All, D extends All>(__namedParameters: { readonly defect: D; readonly error: E;}) => CauseFromSelf<E, D>Cause Utils
CauseEncoded
typeSignature
type CauseEncoded<E, D> = { readonly _tag: "Empty";} | { readonly _tag: "Fail"; readonly error: E;} | { readonly _tag: "Die"; readonly defect: D;} | { readonly _tag: "Interrupt"; readonly fiberId: FiberIdEncoded;} | { readonly _tag: "Sequential"; readonly left: CauseEncoded<E, D>; readonly right: CauseEncoded<E, D>;} | { readonly _tag: "Parallel"; readonly left: CauseEncoded<E, D>; readonly right: CauseEncoded<E, D>;}Chunk
Chunk Transformations
Signature
declare function Chunk<Value extends Any>(value: Value): Chunk<Value>Signature
declare function NonEmptyChunk<Value extends Any>(value: Value): NonEmptyChunk<Value>Classes
Signature
declare const Class: <Self = never>(identifier: string) => <Fields extends Fields>(fieldsOr: Fields | HasFields<Fields>, annotations?: ClassAnnotations<Self, { [K in string | number | symbol]: Type<Fields>[K] }>) => [Self] extends [never] ? "Missing `Self` generic - use `class Self extends Class<Self>()({ ... })`" : Class<Self, Fields, Encoded<Fields>, Context<Fields[keyof Fields]>, Constructor<Fields>, {}, {}>Example
import { Schema } from "effect"
class MyClass extends Schema.Class<MyClass>("MyClass")({ someField: Schema.String}) { someMethod() { return this.someField + "bar" }}Signature
declare const TaggedClass: <Self = never>(identifier?: string) => <Tag extends string, Fields extends Fields>(tag: Tag, fieldsOr: Fields | HasFields<Fields>, annotations?: ClassAnnotations<Self, { [K in string | number | symbol]: Type<{ readonly _tag: tag<Tag>;} & Fields>[K] }>) => [Self] extends [never] ? "Missing `Self` generic - use `class Self extends TaggedClass<Self>()(\"Tag\", { ... })`" : TaggedClass<Self, Tag, { readonly _tag: tag<Tag>;} & Fields>Example
import { Schema } from "effect"
class MyClass extends Schema.TaggedClass<MyClass>("MyClass")("MyClass", { a: Schema.String}) {}Signature
declare function TaggedError<Self = never>(identifier?: string): <Tag extends string, Fields extends Fields>(tag: Tag, fieldsOr: Fields | HasFields<Fields>, annotations?: ClassAnnotations<Self, { [K in string | number | symbol]: Type<{ readonly _tag: tag<Tag>;} & Fields>[K] }>) => [Self] extends [never] ? "Missing `Self` generic - use `class Self extends TaggedError<Self>()(\"Tag\", { ... })`" : TaggedErrorClass<Self, Tag, { readonly _tag: tag<Tag>;} & Fields>Example
import { Schema } from "effect"
class MyError extends Schema.TaggedError<MyError>("MyError")( "MyError", { module: Schema.String, method: Schema.String, description: Schema.String }) { get message(): string { return `${this.module}.${this.method}: ${this.description}` }}Signature
declare const TaggedRequest: <Self = never>(identifier?: string) => <Tag extends string, Payload extends Fields, Success extends All, Failure extends All>(tag: Tag, options: { failure: Failure; payload: Payload; success: Success;}, annotations?: ClassAnnotations<Self, { [K in string | number | symbol]: Type<{ readonly _tag: tag<Tag>;} & Payload>[K] }>) => [Self] extends [never] ? "Missing `Self` generic - use `class Self extends TaggedRequest<Self>()(\"Tag\", SuccessSchema, FailureSchema, { ... })`" : TaggedRequestClass<Self, Tag, { readonly _tag: tag<Tag>;} & Payload, Success, Failure>Example
import { Schema } from "effect"
class MyRequest extends Schema.TaggedRequest<MyRequest>("MyRequest")("MyRequest", { failure: Schema.String, success: Schema.Number, payload: { id: Schema.String }}) {}Combinators
Attaches a property signature with the specified key and value to the schema. This API is useful when you want to add a property to your schema which doesn't describe the shape of the input, but rather maps to another schema, for example when you want to add a discriminant to a simple union.
Signature
declare const attachPropertySignature: { <K extends PropertyKey, V extends symbol | LiteralValue, A>(key: K, value: V, annotations?: Schema<A & { [k in PropertyKey]: V }, readonly []>): <I, R>(schema: Schema<A, I, R>) => SchemaClass<A & { [k in PropertyKey]: V }, I, R>; <A, I, R, K extends PropertyKey, V extends symbol | LiteralValue>(schema: Schema<A, I, R>, key: K, value: V, annotations?: Schema<A & { [k in PropertyKey]: V }, readonly []>): SchemaClass<A & { [k in PropertyKey]: V }, I, R>;}Example
import * as assert from "node:assert"import * as S from "effect/Schema"import { pipe } from "effect/Function"
const Circle = S.Struct({ radius: S.Number })const Square = S.Struct({ sideLength: S.Number })const Shape = S.Union( Circle.pipe(S.attachPropertySignature("kind", "circle")), Square.pipe(S.attachPropertySignature("kind", "square")))
assert.deepStrictEqual(S.decodeSync(Shape)({ radius: 10 }), { kind: "circle", radius: 10})Signature
declare const compose: { <To extends Any, From extends Any, C extends any>(to: To & Schema<Type<To>, C, Context<To>>): (from: From) => transform<From, To>; <To extends Any>(to: To): <From extends Any, B extends any>(from: From & Schema<B, Encoded<From>, Context<From>>) => transform<From, To>; <To extends Any>(to: To, options?: { readonly strict: true; }): <From extends Any>(from: From & Schema<Encoded<To>, Encoded<From>, Context<From>>) => transform<From, To>; <To extends Any>(to: To, options: { readonly strict: false; }): <From extends Any>(from: From) => transform<From, To>; <From extends Any, To extends Any, C extends any>(from: From, to: To & Schema<Type<To>, C, Context<To>>): transform<From, To>; <From extends Any, B extends any, To extends Any>(from: From & Schema<B, Encoded<From>, Context<From>>, to: To): transform<From, To>; <From extends Any, To extends Any>(from: From & Schema<Encoded<To>, Encoded<From>, Context<From>>, to: To, options?: { readonly strict: true; }): transform<From, To>; <From extends Any, To extends Any>(from: From, to: To, options: { readonly strict: false; }): transform<From, To>;}Extends a schema with another schema.
Not all extensions are supported, and their support depends on the nature of the involved schemas.
Possible extensions include:
Schema.Stringwith anotherSchema.Stringrefinement or a string literalSchema.Numberwith anotherSchema.Numberrefinement or a number literalSchema.Booleanwith anotherSchema.Booleanrefinement or a boolean literal- A struct with another struct where overlapping fields support extension
- A struct with in index signature
- A struct with a union of supported schemas
- A refinement of a struct with a supported schema
- A suspend of a struct with a supported schema
- A transformation between structs where the โfromโ and โtoโ sides have no overlapping fields with the target struct
Signature
declare const extend: { <That extends Any>(that: That): <Self extends Any>(self: Self) => extend<Self, That>; <Self extends Any, That extends Any>(self: Self, that: That): extend<Self, That>;}Example
import * as Schema from "effect/Schema"
const schema = Schema.Struct({ a: Schema.String, b: Schema.String})
// const extended: Schema<// {// readonly a: string// readonly b: string// } & {// readonly c: string// } & {// readonly [x: string]: string// }// >const extended = Schema.asSchema(schema.pipe( Schema.extend(Schema.Struct({ c: Schema.String })), // <= you can add more fields Schema.extend(Schema.Record({ key: Schema.String, value: Schema.String })) // <= you can add index signatures))Signature
declare function keyof<A, I, R>(self: Schema<A, I, R>): SchemaClass<keyof A>Creates a new schema with shallow mutability applied to its properties.
Signature
declare const mutable: <S extends Any>(schema: S) => mutable<S>Signature
declare const NullishOr: <S extends All>(self: S) => NullishOr<S>Signature
declare const NullOr: <S extends All>(self: S) => NullOr<S>Signature
declare function partial<A, I, R>(self: Schema<A, I, R>): SchemaClass<{ [K in string | number | symbol]: A[K] }, { [K in string | number | symbol]: I[K] }, R>Signature
declare const partialWith: { <Options extends { readonly exact: true; }>(options: Options): <A, I, R>(self: Schema<A, I, R>) => SchemaClass<{ [K in string | number | symbol]: A[K] }, { [K in string | number | symbol]: I[K] }, R>; <A, I, R, Options extends { readonly exact: true; } | undefined>(self: Schema<A, I, R>, options: Options): SchemaClass<{ [K in string | number | symbol]: A[K] }, { [K in string | number | symbol]: I[K] }, R>;}Signature
declare function required<A, I, R>(self: Schema<A, I, R>): SchemaClass<{ [K in string | number | symbol]: A[K] }, { [K in string | number | symbol]: I[K] }, R>Signature
declare const UndefinedOr: <S extends All>(self: S) => UndefinedOr<S>Signature
declare function Union<Members extends readonly [All, All, All]>(...members: Members): Union<Members>declare function Union<Member extends All>(member: Member): Memberdeclare function Union(): typeof Neverdeclare function Union<Members extends readonly Array<All>>(...members: Members): Schema<Type<Members[number]>, Encoded<Members[number]>, Context<Members[number]>>Config Validations
Constructor Utils
MakeOptions
typeSignature
type MakeOptions = boolean | { readonly disableValidation?: boolean;}Constructors
Signature
declare function ArrayEnsure<Value extends Any>(value: Value): ArrayEnsure<Value>The constraint R extends Schema.Context<P[number]> enforces dependencies solely from typeParameters.
This ensures that when you call Schema.to or Schema.from, you receive a schema with a never context.
Signature
declare const declare: { <A>(is: (input: unknown) => input is A, annotations?: Schema<A, readonly []>): declare<A>; <A, I, P extends readonly Array<All>>(typeParameters: P, options: { readonly decode: (...typeParameters: { [K in string | number | symbol]: Schema<Type<P[K]>, Encoded<P[K]>, never> }) => (input: unknown, options: ParseOptions, ast: Declaration) => Effect<A, ParseIssue, never>; readonly encode: (...typeParameters: { [K in string | number | symbol]: Schema<Type<P[K]>, Encoded<P[K]>, never> }) => (input: unknown, options: ParseOptions, ast: Declaration) => Effect<I, ParseIssue, never>; }, annotations?: Schema<A, { [K in string | number | symbol]: Type<P[K]> }>): declare<A, I, P>;}Signature
declare const Enums: <A extends EnumsDefinition>(enums: A) => Enums<A>Signature
declare function fromBrand<C extends Brand<string | symbol>, A extends Brand<string | symbol>>(constructor: Constructor<C>, annotations?: Filter<C, A>): <I, R>(self: Schema<A, I, R>) => BrandSchema<A & C, I, R>Signature
declare const instanceOf: <A extends (...args: any) => any>(constructor: A, annotations?: Schema<InstanceType<A>, readonly []>) => instanceOf<InstanceType<A>>Signature
declare function Literal<Literals extends readonly [LiteralValue, LiteralValue]>(...literals: Literals): Literal<Literals>declare function Literal(): Neverdeclare function Literal<Literals extends readonly Array<LiteralValue>>(...literals: Literals): SchemaClass<Literals[number]>Signature
declare function make<A, I = A, R = never>(ast: AST): SchemaClass<A, I, R>Signature
declare const NonEmptyArray: <Value extends Any>(value: Value) => NonEmptyArray<Value>Signature
declare function NonEmptyArrayEnsure<Value extends Any>(value: Value): NonEmptyArrayEnsure<Value>Creates a new Schema from a literal schema.
Signature
declare function pickLiteral<A extends LiteralValue, L extends readonly [A, A]>(...literals: L): <I, R>(_schema: Schema<A, I, R>) => Literal<[...Array<L>]>Example
import * as assert from "node:assert"import { Either, Schema } from "effect"
const schema = Schema.Literal("a", "b", "c").pipe(Schema.pickLiteral("a", "b"))
assert.deepStrictEqual(Schema.decodeSync(schema)("a"), "a")assert.deepStrictEqual(Schema.decodeSync(schema)("b"), "b")assert.strictEqual(Either.isLeft(Schema.decodeUnknownEither(schema)("c")), true)Signature
declare function Record<K extends All, V extends All>(options: { readonly key: K; readonly value: V;}): Record$<K, V>Signature
declare function Struct<Fields extends Fields, Records extends readonly [Record, Record]>(fields: Fields, ...records: Records): TypeLiteral<Fields, Records>declare function Struct<Fields extends Fields>(fields: Fields): Struct<Fields>Signature
declare const suspend: <A, I, R>(f: () => Schema<A, I, R>) => suspend<A, I, R>A tagged struct is a struct that has a tag property that is used to distinguish between different types of objects.
The tag is optional when using the make method.
Signature
declare const TaggedStruct: <Tag extends LiteralValue, Fields extends Fields>(value: Tag, fields: Fields) => TaggedStruct<Tag, Fields>Example
import * as assert from "node:assert"import { Schema } from "effect"
const User = Schema.TaggedStruct("User", { name: Schema.String, age: Schema.Number})
assert.deepStrictEqual(User.make({ name: "John", age: 44 }), { _tag: "User", name: "John", age: 44 })Creates a new Schema which transforms literal values.
Signature
declare function transformLiteral<Encoded extends LiteralValue, Type extends LiteralValue>(from: Encoded, to: Type): transformLiteral<Type, Encoded>Example
import * as assert from "node:assert"import * as S from "effect/Schema"
const schema = S.transformLiteral(0, "a")
assert.deepStrictEqual(S.decodeSync(schema)(0), "a")Creates a new Schema which maps between corresponding literal values.
Signature
declare function transformLiterals<A extends readonly [readonly [LiteralValue, LiteralValue], readonly [LiteralValue, LiteralValue], readonly [LiteralValue, LiteralValue]]>(...pairs: A): Union<{ [I in string | number | symbol]: transformLiteral<A[I][1], A[I][0]> }>declare function transformLiterals<Encoded extends LiteralValue, Type extends LiteralValue>(pairs: [Encoded, Type]): transformLiteral<Type, Encoded>declare function transformLiterals<A extends readonly Array<readonly [LiteralValue, LiteralValue]>>(...pairs: A): Schema<A[number][1], A[number][0]>Example
import * as assert from "node:assert"import * as S from "effect/Schema"
const Animal = S.transformLiterals( [0, "cat"], [1, "dog"], [2, "cow"])
assert.deepStrictEqual(S.decodeSync(Animal)(1), "dog")Signature
declare function Tuple<Elements extends Elements, Rest extends readonly [Any | Element<Any, "">, Any | Element<Any, "">]>(elements: Elements, ...rest: Rest): TupleType<Elements, Rest>declare function Tuple<Fst extends Any, Snd extends Any>(fst: Fst, snd: Snd): Tuple2<Fst, Snd>declare function Tuple<Elements extends Elements>(...elements: Elements): Tuple<Elements>Signature
declare function UniqueSymbolFromSelf<S extends symbol>(symbol: S): SchemaClass<S>Data Transformations
Type and Encoded must extend Readonly<Record<string, any>> | ReadonlyArray<any> to be compatible with this API.
Signature
declare const Data: <S extends Any, A extends readonly Array<unknown> | Readonly<Record<string, unknown>>, I extends readonly Array<unknown> | Readonly<Record<string, unknown>>>(value: S & Schema<A & Type<S>, I & Encoded<S>, Context<S>>) => Data<S>Type and Encoded must extend Readonly<Record<string, any>> | ReadonlyArray<any> to be compatible with this API.
Signature
declare const DataFromSelf: <S extends Any, A extends readonly Array<unknown> | Readonly<Record<string, unknown>>, I extends readonly Array<unknown> | Readonly<Record<string, unknown>>>(value: S & Schema<A & Type<S>, I & Encoded<S>, Context<S>>) => DataFromSelf<S>Date Constructors
Describes a schema that accommodates potentially invalid Date instances,
such as new Date("Invalid Date"), without rejection.
Signature
declare class DateFromSelf extends Variance<Date, Date, never, this> { constructor(_: never);}Defines a schema that ensures only valid dates are accepted. This schema
rejects values like new Date("Invalid Date"), which, despite being a Date
instance, represents an invalid date. Such stringent validation ensures that
all date objects processed through this schema are properly formed and
represent real dates.
Signature
declare class ValidDateFromSelf extends Variance<Date, Date, never, this> { constructor(_: never);}Date Filters
Signature
declare function betweenDate<S extends Any>(min: Date, max: Date, annotations?: Filter<Type<S>, Type<S>>): <A extends Date>(self: S & Schema<A, Encoded<S>, Context<S>>) => filter<S>Signature
declare function greaterThanDate<S extends Any>(min: Date, annotations?: Filter<Type<S>, Type<S>>): <A extends Date>(self: S & Schema<A, Encoded<S>, Context<S>>) => filter<S>Signature
declare function greaterThanOrEqualToDate<S extends Any>(min: Date, annotations?: Filter<Type<S>, Type<S>>): <A extends Date>(self: S & Schema<A, Encoded<S>, Context<S>>) => filter<S>Signature
declare function lessThanDate<S extends Any>(max: Date, annotations?: Filter<Type<S>, Type<S>>): <A extends Date>(self: S & Schema<A, Encoded<S>, Context<S>>) => filter<S>Signature
declare function lessThanOrEqualToDate<S extends Any>(max: Date, annotations?: Filter<Type<S>, Type<S>>): <A extends Date>(self: S & Schema<A, Encoded<S>, Context<S>>) => filter<S>Defines a filter that specifically rejects invalid dates, such as new Date("Invalid Date"). This filter ensures that only properly formatted and
valid date objects are accepted, enhancing data integrity by preventing
erroneous date values from being processed.
Signature
declare function validDate<S extends Any>(annotations?: Filter<Type<S>, Type<S>>): <A extends Date>(self: S & Schema<A, Encoded<S>, Context<S>>) => filter<S>Date Transformations
Defines a schema that converts a number into a Date object using the new Date constructor. This schema does not validate the numerical input,
allowing potentially invalid values such as NaN, Infinity, and
-Infinity to be converted into Date objects. During the encoding process,
any invalid Date object will be encoded to NaN.
Signature
declare class DateFromNumber extends Variance<Date, number, never, this> { constructor(_: never);}Defines a schema that attempts to convert a string to a Date object using
the new Date constructor. This conversion is lenient, meaning it does not
reject strings that do not form valid dates (e.g., using new Date("Invalid Date") results in a Date object, despite being invalid).
Signature
declare class DateFromString extends Variance<Date, string, never, this> { constructor(_: never);}DateTime.Utc Constructors
Describes a schema that represents a DateTime.Utc instance.
Signature
declare class DateTimeUtcFromSelf extends Variance<Utc, Utc, never, this> { constructor(_: never);}DateTime.Utc Transformations
Defines a schema that attempts to convert a string to a DateTime.Utc instance using the DateTime.unsafeMake constructor.
Signature
declare class DateTimeUtc extends Variance<Utc, string, never, this> { constructor(_: never);}Defines a schema that attempts to convert a Date to a DateTime.Utc instance using the DateTime.unsafeMake constructor.
Signature
declare class DateTimeUtcFromDate extends Variance<Utc, Date, never, this> { constructor(_: never);}Defines a schema that attempts to convert a number to a DateTime.Utc instance using the DateTime.unsafeMake constructor.
Signature
declare class DateTimeUtcFromNumber extends Variance<Utc, number, never, this> { constructor(_: never);}DateTime.Zoned Constructors
Describes a schema that represents a DateTime.Zoned instance.
Signature
declare class DateTimeZonedFromSelf extends Variance<Zoned, Zoned, never, this> { constructor(_: never);}DateTime.Zoned Transformations
Defines a schema that attempts to convert a string to a DateTime.Zoned instance.
Signature
declare class DateTimeZoned extends Variance<Zoned, string, never, this> { constructor(_: never);}Decoding
Signature
declare const decode: <A, I, R>(schema: Schema<A, I, R>, options?: ParseOptions) => (i: I, overrideOptions?: ParseOptions) => Effect.Effect<A, ParseResult.ParseError, R>Signature
declare const decodeEither: <A, I>(schema: Schema<A, I, never>, options?: ParseOptions) => (i: I, overrideOptions?: ParseOptions) => either_.Either<A, ParseResult.ParseError>Signature
declare const decodeOption: <A, I>(schema: Schema.Schema<A, I, never>, options?: AST.ParseOptions) => (i: I, overrideOptions?: AST.ParseOptions) => Option.Option<A>Signature
declare const decodePromise: <A, I>(schema: Schema<A, I, never>, options?: ParseOptions) => (i: I, overrideOptions?: ParseOptions) => Promise<A>Signature
declare const decodeSync: <A, I>(schema: Schema.Schema<A, I, never>, options?: AST.ParseOptions) => (i: I, overrideOptions?: AST.ParseOptions) => ASignature
declare function decodeUnknown<A, I, R>(schema: Schema<A, I, R>, options?: ParseOptions): (u: unknown, overrideOptions?: ParseOptions) => Effect<A, ParseError, R>Signature
declare function decodeUnknownEither<A, I>(schema: Schema<A, I, never>, options?: ParseOptions): (u: unknown, overrideOptions?: ParseOptions) => Either<A, ParseError>Signature
declare function decodeUnknownOption<A, I>(schema: Schema<A, I, never>, options?: ParseOptions): (u: unknown, overrideOptions?: ParseOptions) => Option<A>Signature
declare function decodeUnknownPromise<A, I>(schema: Schema<A, I, never>, options?: ParseOptions): (u: unknown, overrideOptions?: ParseOptions) => Promise<A>Signature
declare function decodeUnknownSync<A, I>(schema: Schema<A, I, never>, options?: ParseOptions): (u: unknown, overrideOptions?: ParseOptions) => ASignature
declare const deserialize: { (value: unknown): <A, I, R>(self: Serializable<A, I, R>) => Effect<A, ParseError, R>; <A, I, R>(self: Serializable<A, I, R>, value: unknown): Effect<A, ParseError, R>;}Signature
declare const deserializeExit: { (value: unknown): <SA, SI, FA, FI, R>(self: WithResult<SA, SI, FA, FI, R>) => Effect<Exit<SA, FA>, ParseError, R>; <SA, SI, FA, FI, R>(self: WithResult<SA, SI, FA, FI, R>, value: unknown): Effect<Exit<SA, FA>, ParseError, R>;}Signature
declare const deserializeFailure: { (value: unknown): <SA, SI, FA, FI, R>(self: WithResult<SA, SI, FA, FI, R>) => Effect<FA, ParseError, R>; <SA, SI, FA, FI, R>(self: WithResult<SA, SI, FA, FI, R>, value: unknown): Effect<FA, ParseError, R>;}Signature
declare const deserializeSuccess: { (value: unknown): <SA, SI, FA, FI, R>(self: WithResult<SA, SI, FA, FI, R>) => Effect<SA, ParseError, R>; <SA, SI, FA, FI, R>(self: WithResult<SA, SI, FA, FI, R>, value: unknown): Effect<SA, ParseError, R>;}Defect
Defines a schema for handling JavaScript errors (Error instances) and other types of defects.
It decodes objects into Error instances if they match the expected structure (i.e., have a message and optionally a name and stack),
or converts other values to their string representations.
When encoding, it converts Error instances back into plain objects containing only the error's name and message,
or other values into their string forms.
This is useful for serializing and deserializing errors across network boundaries where error objects do not natively serialize.
Signature
declare class Defect extends Variance<unknown, unknown, never, this> { constructor(_: never);}Duration Constructors
Signature
declare class DurationFromSelf extends Variance<Duration, Duration, never, this> { constructor(_: never);}Duration Filters
Signature
declare function betweenDuration<S extends Any>(minimum: DurationInput, maximum: DurationInput, annotations?: Filter<Type<S>, Type<S>>): <A extends Duration>(self: S & Schema<A, Encoded<S>, Context<S>>) => filter<S>Signature
declare function greaterThanDuration<S extends Any>(min: DurationInput, annotations?: Filter<Type<S>, Type<S>>): <A extends Duration>(self: S & Schema<A, Encoded<S>, Context<S>>) => filter<S>Signature
declare function greaterThanOrEqualToDuration<S extends Any>(min: DurationInput, annotations?: Filter<Type<S>, Type<S>>): <A extends Duration>(self: S & Schema<A, Encoded<S>, Context<S>>) => filter<S>Signature
declare function lessThanDuration<S extends Any>(max: DurationInput, annotations?: Filter<Type<S>, Type<S>>): <A extends Duration>(self: S & Schema<A, Encoded<S>, Context<S>>) => filter<S>Signature
declare function lessThanOrEqualToDuration<S extends Any>(max: DurationInput, annotations?: Filter<Type<S>, Type<S>>): <A extends Duration>(self: S & Schema<A, Encoded<S>, Context<S>>) => filter<S>Duration Transformations
Clamps a Duration between a minimum and a maximum value.
Signature
declare function clampDuration(minimum: DurationInput, maximum: DurationInput): <S extends Any, A extends Duration>(self: S & Schema<A, Encoded<S>, Context<S>>) => transform<S, filter<SchemaClass<A, A, never>>>A schema that converts a JSON-compatible tagged union into a Duration.
Signature
declare class Duration extends Variance<Duration, DurationEncoded | readonly [number, number], never, this> { constructor(_: never);}A schema that transforms a (possibly Infinite) non negative number into a
Duration. Treats the value as the number of milliseconds.
Signature
declare class DurationFromMillis extends Variance<Duration, number, never, this> { constructor(_: never);}A schema that transforms a non negative bigint into a Duration. Treats
the value as the number of nanoseconds.
Signature
declare class DurationFromNanos extends Variance<Duration, bigint, never, this> { constructor(_: never);}Duration Utils
DurationEncoded
typeSignature
type DurationEncoded = { readonly _tag: "Millis"; readonly millis: number;} | { readonly _tag: "Nanos"; readonly nanos: string;} | { readonly _tag: "Infinity";}Either Transformations
Signature
declare const Either: <R extends All, L extends All>(__namedParameters: { readonly left: L; readonly right: R;}) => Either<R, L>Signature
declare const EitherFromSelf: <R extends All, L extends All>(__namedParameters: { readonly left: L; readonly right: R;}) => EitherFromSelf<R, L>Signature
declare const EitherFromUnion: <Right extends All, Left extends All>(__namedParameters: { readonly left: Left; readonly right: Right;}) => EitherFromUnion<Right, Left>Example
import * as Schema from "effect/Schema"
// Schema<string | number, Either<string, number>>Schema.EitherFromUnion({ left: Schema.String, right: Schema.Number })Either Utils
EitherEncoded
typeSignature
type EitherEncoded<IR, IL> = RightEncoded<IR> | LeftEncoded<IL>LeftEncoded
typeSignature
type LeftEncoded<IE> = { readonly _tag: "Left"; readonly left: IE;}RightEncoded
typeSignature
type RightEncoded<IA> = { readonly _tag: "Right"; readonly right: IA;}Encoding
Signature
declare const encode: <A, I, R>(schema: Schema<A, I, R>, options?: ParseOptions) => (a: A, overrideOptions?: ParseOptions) => Effect.Effect<I, ParseResult.ParseError, R>Signature
declare const encodeEither: <A, I>(schema: Schema<A, I, never>, options?: ParseOptions) => (a: A, overrideOptions?: ParseOptions) => either_.Either<I, ParseResult.ParseError>Signature
declare const encodeOption: <A, I>(schema: Schema.Schema<A, I, never>, options?: AST.ParseOptions) => (input: A, overrideOptions?: AST.ParseOptions) => Option.Option<I>Signature
declare const encodePromise: <A, I>(schema: Schema<A, I, never>, options?: ParseOptions) => (a: A, overrideOptions?: ParseOptions) => Promise<I>Signature
declare const encodeSync: <A, I>(schema: Schema.Schema<A, I, never>, options?: AST.ParseOptions) => (a: A, overrideOptions?: AST.ParseOptions) => ISignature
declare function encodeUnknown<A, I, R>(schema: Schema<A, I, R>, options?: ParseOptions): (u: unknown, overrideOptions?: ParseOptions) => Effect<I, ParseError, R>Signature
declare function encodeUnknownEither<A, I>(schema: Schema<A, I, never>, options?: ParseOptions): (u: unknown, overrideOptions?: ParseOptions) => Either<I, ParseError>Signature
declare function encodeUnknownOption<A, I>(schema: Schema<A, I, never>, options?: ParseOptions): (u: unknown, overrideOptions?: ParseOptions) => Option<I>Signature
declare function encodeUnknownPromise<A, I>(schema: Schema<A, I, never>, options?: ParseOptions): (u: unknown, overrideOptions?: ParseOptions) => Promise<I>Signature
declare function encodeUnknownSync<A, I>(schema: Schema<A, I, never>, options?: ParseOptions): (u: unknown, overrideOptions?: ParseOptions) => ISignature
declare function serialize<A, I, R>(self: Serializable<A, I, R>): Effect<I, ParseError, R>Signature
declare const serializeExit: { <SA, FA>(value: Exit<SA, FA>): <SI, FI, R>(self: WithResult<SA, SI, FA, FI, R>) => Effect<ExitEncoded<SI, FI, unknown>, ParseError, R>; <SA, SI, FA, FI, R>(self: WithResult<SA, SI, FA, FI, R>, value: Exit<SA, FA>): Effect<ExitEncoded<SI, FI, unknown>, ParseError, R>;}Signature
declare const serializeFailure: { <FA>(value: FA): <SA, SI, FI, R>(self: WithResult<SA, SI, FA, FI, R>) => Effect<FI, ParseError, R>; <SA, SI, FA, FI, R>(self: WithResult<SA, SI, FA, FI, R>, value: FA): Effect<FI, ParseError, R>;}Signature
declare const serializeSuccess: { <SA>(value: SA): <SI, FA, FI, R>(self: WithResult<SA, SI, FA, FI, R>) => Effect<SI, ParseError, R>; <SA, SI, FA, FI, R>(self: WithResult<SA, SI, FA, FI, R>, value: SA): Effect<SI, ParseError, R>;}Equivalence
Given a schema Schema<A, I, R>, returns an Equivalence instance for A.
Signature
declare function equivalence<A, I, R>(schema: Schema<A, I, R>): Equivalence<A>Exit Transformations
Signature
declare const Exit: <A extends All, E extends All, D extends All>(__namedParameters: { readonly defect: D; readonly failure: E; readonly success: A;}) => Exit<A, E, D>Signature
declare const ExitFromSelf: <A extends All, E extends All, D extends All>(__namedParameters: { readonly defect: D; readonly failure: E; readonly success: A;}) => ExitFromSelf<A, E, D>Exit Utils
ExitEncoded
typeSignature
type ExitEncoded<A, E, D> = { readonly _tag: "Failure"; readonly cause: CauseEncoded<E, D>;} | { readonly _tag: "Success"; readonly value: A;}FiberId
FiberIdEncoded
typeSignature
type FiberIdEncoded = { readonly _tag: "Composite"; readonly left: FiberIdEncoded; readonly right: FiberIdEncoded;} | { readonly _tag: "None";} | { readonly _tag: "Runtime"; readonly id: number; readonly startTimeMillis: number;}FiberId Constructors
Signature
declare class FiberIdFromSelf extends Variance<FiberId, FiberId, never, this> { constructor(_: never);}FiberId Transformations
Filtering
Signature
declare function filter<C, B, A = C>(refinement: (a: A, options: ParseOptions, self: Refinement) => a is B, annotations?: Filter<C & B, C>): <I, R>(self: Schema<C, I, R>) => refine<C & B, Schema<A, I, R>>declare function filter<A, B>(refinement: (a: A, options: ParseOptions, self: Refinement) => a is B, annotations?: Filter<B, A>): <I, R>(self: Schema<A, I, R>) => refine<B, Schema<A, I, R>>declare function filter<S extends Any>(predicate: (a: NoInfer<Type<S>>, options: ParseOptions, self: Refinement) => FilterReturnType, annotations?: Filter<NoInfer<Type<S>>, NoInfer<Type<S>>>): (self: S) => filter<S>FilterIssue
interfaceSignature
interface FilterIssue { readonly message: string; readonly path: readonly Array<PropertyKey>;}FilterOutput
typeSignature
type FilterOutput = undefined | boolean | string | ParseResult.ParseIssue | FilterIssueFormatting
Guards
Signature
declare function isPropertySignature(u: unknown): u is All<PropertyKey>Tests if a value is a Schema.
Signature
declare function isSchema(u: unknown): u is AnyHashMap Transformations
Signature
declare const HashMap: <K extends Any, V extends Any>(__namedParameters: { readonly key: K; readonly value: V;}) => HashMap<K, V>Signature
declare const HashMapFromSelf: <K extends Any, V extends Any>(__namedParameters: { readonly key: K; readonly value: V;}) => HashMapFromSelf<K, V>HashSet Transformations
Signature
declare function HashSet<Value extends Any>(value: Value): HashSet<Value>Signature
declare const HashSetFromSelf: <Value extends Any>(value: Value) => HashSetFromSelf<Value>List Transformations
Signature
declare function List<Value extends Any>(value: Value): List<Value>Signature
declare const ListFromSelf: <Value extends Any>(value: Value) => ListFromSelf<Value>Map
Signature
declare const MapFromSelf: <K extends Any, V extends Any>(__namedParameters: { readonly key: K; readonly value: V;}) => MapFromSelf<K, V>Map Transformations
Signature
declare function MapFromRecord<KA, KR, VA, VI, VR>(__namedParameters: { key: Schema<KA, string, KR>; value: Schema<VA, VI, VR>;}): SchemaClass<Map<KA, VA>, { [x: string]: VI;}, KR | VR>Model
Signature
interface Schema<in out A, in out I = A, out R = never> extends Variance<A, I, R>, Pipeable { readonly ast: AST; readonly Context: R; readonly Encoded: I; readonly Type: A; annotations(annotations: GenericSchema<A>): Schema<A, I, R>;}SchemaClass
interfaceSignature
interface SchemaClass<A, I = A, R = never> extends AnnotableClass<SchemaClass<A, I, R>, A, I, R> { constructor(_: never);}Serializable
interfaceThe Serializable trait allows objects to define their own schema for
serialization.
Signature
interface Serializable<A, I, R> { readonly [symbolSerializable]: Schema<A, I, R>;}SerializableWithResult
interfaceThe SerializableWithResult trait is specifically designed to model remote
procedures that require serialization of their input and output, managing
both successful and failed outcomes.
This trait combines functionality from both the Serializable and WithResult
traits to handle data serialization and the bifurcation of operation results
into success or failure categories.
Signature
interface SerializableWithResult<A, I, R, Success, SuccessEncoded, Failure, FailureEncoded, ResultR> extends Serializable<A, I, R>, WithResult<Success, SuccessEncoded, Failure, FailureEncoded, ResultR> {}WithResult
interfaceThe WithResult trait is designed to encapsulate the outcome of an
operation, distinguishing between success and failure cases. Each case is
associated with a schema that defines the structure and types of the success
or failure data.
Signature
interface WithResult<Success, SuccessEncoded, Failure, FailureEncoded, ResultR> { readonly [symbolWithResult]: { readonly failure: Schema<Failure, FailureEncoded, ResultR>; readonly success: Schema<Success, SuccessEncoded, ResultR>; };}NonEmptyReadonlyArray Transformations
Get the first element of a NonEmptyReadonlyArray.
Signature
declare function headNonEmpty<S extends Any, A extends readonly [unknown, unknown]>(self: S & Schema<A, Encoded<S>, Context<S>>): transform<S, SchemaClass<A[number], A[number], never>>Number Constructors
Signature
declare class Finite extends Variance<number, number, never, this> { constructor(_: never);}Signature
declare class Int extends Variance<number, number, never, this> { constructor(_: never);}The JsonNumber is a schema for representing JSON numbers. It ensures that the provided value is a valid
number by filtering out NaN and (+/-) Infinity. This is useful when you want to validate and represent numbers in JSON
format.
Signature
declare class JsonNumber extends Variance<number, number, never, this> { constructor(_: never);}Example
import * as assert from "node:assert"import * as Schema from "effect/Schema"
const is = Schema.is(Schema.JsonNumber)
assert.deepStrictEqual(is(42), true)assert.deepStrictEqual(is(Number.NaN), false)assert.deepStrictEqual(is(Number.POSITIVE_INFINITY), false)assert.deepStrictEqual(is(Number.NEGATIVE_INFINITY), false)Signature
declare class Negative extends Variance<number, number, never, this> { constructor(_: never);}Signature
declare class NonNaN extends Variance<number, number, never, this> { constructor(_: never);}Signature
declare class NonNegative extends Variance<number, number, never, this> { constructor(_: never);}A non-negative integer. +Infinity is excluded.
Signature
declare const NonNegativeInt: refine<number, typeof NonNegative>Signature
declare class NonPositive extends Variance<number, number, never, this> { constructor(_: never);}Signature
declare class Positive extends Variance<number, number, never, this> { constructor(_: never);}Signature
declare class Uint8 extends Variance<number, number, never, this> { constructor(_: never);}Number Filters
This filter checks whether the provided number falls within the specified minimum and maximum values.
Signature
declare function between<S extends Any>(minimum: number, maximum: number, annotations?: Filter<Type<S>, Type<S>>): <A extends number>(self: S & Schema<A, Encoded<S>, Context<S>>) => filter<S>Ensures that the provided value is a finite number (excluding NaN, +Infinity, and -Infinity).
Signature
declare function finite<S extends Any>(annotations?: Filter<Type<S>, Type<S>>): <A extends number>(self: S & Schema<A, Encoded<S>, Context<S>>) => filter<S>This filter checks whether the provided number is greater than the specified minimum.
Signature
declare function greaterThan<S extends Any>(exclusiveMinimum: number, annotations?: Filter<Type<S>, Type<S>>): <A extends number>(self: S & Schema<A, Encoded<S>, Context<S>>) => filter<S>This filter checks whether the provided number is greater than or equal to the specified minimum.
Signature
declare function greaterThanOrEqualTo<S extends Any>(minimum: number, annotations?: Filter<Type<S>, Type<S>>): <A extends number>(self: S & Schema<A, Encoded<S>, Context<S>>) => filter<S>Ensures that the provided value is an integer number (excluding NaN, +Infinity, and -Infinity).
Signature
declare function int<S extends Any>(annotations?: Filter<Type<S>, Type<S>>): <A extends number>(self: S & Schema<A, Encoded<S>, Context<S>>) => filter<S>This filter checks whether the provided number is less than the specified maximum.
Signature
declare function lessThan<S extends Any>(exclusiveMaximum: number, annotations?: Filter<Type<S>, Type<S>>): <A extends number>(self: S & Schema<A, Encoded<S>, Context<S>>) => filter<S>This schema checks whether the provided number is less than or equal to the specified maximum.
Signature
declare function lessThanOrEqualTo<S extends Any>(maximum: number, annotations?: Filter<Type<S>, Type<S>>): <A extends number>(self: S & Schema<A, Encoded<S>, Context<S>>) => filter<S>Signature
declare function multipleOf<S extends Any>(divisor: number, annotations?: Filter<Type<S>, Type<S>>): <A extends number>(self: S & Schema<A, Encoded<S>, Context<S>>) => filter<S>Signature
declare function negative<S extends Any>(annotations?: Filter<Type<S>, Type<S>>): <A extends number>(self: S & Schema<A, Encoded<S>, Context<S>>) => filter<S>Signature
declare function nonNaN<S extends Any>(annotations?: Filter<Type<S>, Type<S>>): <A extends number>(self: S & Schema<A, Encoded<S>, Context<S>>) => filter<S>Signature
declare function nonNegative<S extends Any>(annotations?: Filter<Type<S>, Type<S>>): <A extends number>(self: S & Schema<A, Encoded<S>, Context<S>>) => filter<S>Signature
declare function nonPositive<S extends Any>(annotations?: Filter<Type<S>, Type<S>>): <A extends number>(self: S & Schema<A, Encoded<S>, Context<S>>) => filter<S>Signature
declare function positive<S extends Any>(annotations?: Filter<Type<S>, Type<S>>): <A extends number>(self: S & Schema<A, Encoded<S>, Context<S>>) => filter<S>Number Transformations
Clamps a number between a minimum and a maximum value.
Signature
declare function clamp(minimum: number, maximum: number): <S extends Any, A extends number>(self: S & Schema<A, Encoded<S>, Context<S>>) => transform<S, filter<SchemaClass<A, A, never>>>This schema transforms a string into a number by parsing the string using the parse function of the effect/Number module.
It returns an error if the value can't be converted (for example when non-numeric characters are provided).
The following special string values are supported: "NaN", "Infinity", "-Infinity".
Signature
declare class NumberFromString extends Variance<number, string, never, this> { constructor(_: never);}Transforms a string into a number by parsing the string using the parse
function of the effect/Number module.
It returns an error if the value can't be converted (for example when non-numeric characters are provided).
The following special string values are supported: "NaN", "Infinity", "-Infinity".
Signature
declare function parseNumber<S extends Any, A extends string>(self: S & Schema<A, Encoded<S>, Context<S>>): transformOrFail<S, typeof Number$>Option Transformations
Signature
declare function Option<Value extends Any>(value: Value): Option<Value>Transforms strings into an Option type, effectively filtering out empty or
whitespace-only strings by trimming them and checking their length. Returns
none for invalid inputs and some for valid non-empty strings.
Signature
declare class OptionFromNonEmptyTrimmedString extends Variance<Option<string>, string, never, this> { constructor(_: never);}Example
import { Schema } from "effect"
console.log(Schema.decodeSync(Schema.OptionFromNonEmptyTrimmedString)("")) // Option.none()console.log(Schema.decodeSync(Schema.OptionFromNonEmptyTrimmedString)(" a ")) // Option.some("a")console.log(Schema.decodeSync(Schema.OptionFromNonEmptyTrimmedString)("a")) // Option.some("a")Signature
declare function OptionFromNullishOr<Value extends Any>(value: Value, onNoneEncoding: null | undefined): OptionFromNullishOr<Value>Signature
declare function OptionFromNullOr<Value extends Any>(value: Value): OptionFromNullOr<Value>Signature
declare const OptionFromSelf: <Value extends Any>(value: Value) => OptionFromSelf<Value>Signature
declare function OptionFromUndefinedOr<Value extends Any>(value: Value): OptionFromUndefinedOr<Value>Option Utils
OptionEncoded
typeSignature
type OptionEncoded<I> = { readonly _tag: "None";} | { readonly _tag: "Some"; readonly value: I;}Other
Signature
declare function asSchema<S extends All>(schema: S): Schema<Type<S>, Encoded<S>, Context<S>>Signature
declare function asSerializable<S extends All>(serializable: S): Serializable<Type<S>, Encoded<S>, Context<S>>Signature
declare function asSerializableWithResult<SWR extends All>(procedure: SWR): SerializableWithResult<Type<SWR>, Encoded<SWR>, Context<SWR>, Success<SWR>, SuccessEncoded<SWR>, Failure<SWR>, FailureEncoded<SWR>, Context<SWR>>Signature
declare function asWithResult<WR extends All>(withExit: WR): WithResult<Success<WR>, SuccessEncoded<WR>, Failure<WR>, FailureEncoded<WR>, Context<WR>>Signature
declare function element<S extends Any>(self: S): Element<S, "">The encodedBoundSchema function is similar to encodedSchema but preserves
the refinements up to the first transformation point in the original schema.
Signature
declare function encodedBoundSchema<A, I, R>(schema: Schema<A, I, R>): SchemaClass<I>The encodedSchema function allows you to extract the Encoded portion of a
schema, creating a new schema that conforms to the properties defined in the
original schema without retaining any refinements or transformations that
were applied previously.
Signature
declare function encodedSchema<A, I, R>(schema: Schema<A, I, R>): SchemaClass<I>EnumsDefinition
typeSignature
type EnumsDefinition = { [x: string]: string | number;}Signature
declare function optionalElement<S extends Any>(self: S): Element<S, "?">OptionalOptions
typeSignature
type OptionalOptions<A> = { readonly as?: never; readonly default?: never; readonly exact?: true; readonly nullable?: true;} | { readonly as?: never; readonly default: LazyArg<A>; readonly exact?: true; readonly nullable?: true;} | { readonly as: "Option"; readonly default?: never; readonly exact?: never; readonly nullable?: never; readonly onNoneEncoding?: LazyArg<option_.Option<undefined>>;} | { readonly as: "Option"; readonly default?: never; readonly exact?: never; readonly nullable: true; readonly onNoneEncoding?: LazyArg<option_.Option<null | undefined>>;} | { readonly as: "Option"; readonly default?: never; readonly exact: true; readonly nullable?: never; readonly onNoneEncoding?: never;} | { readonly as: "Option"; readonly default?: never; readonly exact: true; readonly nullable: true; readonly onNoneEncoding?: LazyArg<option_.Option<null>>;} | undefinedParseJsonOptions
typeSignature
type ParseJsonOptions = { readonly replacer?: Parameters<typeof JSON.stringify>[1]; readonly reviver?: Parameters<typeof JSON.parse>[1]; readonly space?: Parameters<typeof JSON.stringify>[2];}Signature
type Simplify<A> = { [K in keyof A]: A[K] } & {}SimplifyMutable
typeSignature
type SimplifyMutable<A> = { [K in keyof A]: A[K] } extends infer B ? B : neverReturns a property signature that represents a tag.
A tag is a literal value that is used to distinguish between different types of objects.
The tag is optional when using the make method.
See
Signature
declare const tag: <Tag extends LiteralValue>(tag: Tag) => tag<Tag>Example
import * as assert from "node:assert"import { Schema } from "effect"
const User = Schema.Struct({ _tag: Schema.tag("User"), name: Schema.String, age: Schema.Number})
assert.deepStrictEqual(User.make({ name: "John", age: 44 }), { _tag: "User", name: "John", age: 44 })TaggedRequest
interfaceSignature
interface TaggedRequest<Tag extends string, A, I, R, SuccessType, SuccessEncoded, FailureType, FailureEncoded, ResultR> extends Request<SuccessType, FailureType>, SerializableWithResult<A, I, R, SuccessType, SuccessEncoded, FailureType, FailureEncoded, ResultR> { readonly _tag: Tag;}The typeSchema function allows you to extract the Type portion of a
schema, creating a new schema that conforms to the properties defined in the
original schema without considering the initial encoding or transformation
processes.
Signature
declare function typeSchema<A, I, R>(schema: Schema<A, I, R>): SchemaClass<A>Primitives
Signature
declare class Any extends Variance<any, any, never, this> { constructor(_: never);}Signature
declare class BigIntFromSelf extends Variance<bigint, bigint, never, this> { constructor(_: never);}Signature
declare class Never extends Variance<never, never, never, this> { constructor(_: never);}Signature
declare class Null extends Variance<null, null, never, this> { constructor(_: never);}Signature
declare class SymbolFromSelf extends Variance<symbol, symbol, never, this> { constructor(_: never);}Signature
declare class Undefined extends Variance<undefined, undefined, never, this> { constructor(_: never);}Signature
declare class Unknown extends Variance<unknown, unknown, never, this> { constructor(_: never);}Signature
declare class Void extends Variance<void, void, never, this> { constructor(_: never);}PropertySignature
Enhances a property signature by specifying a different key for it in the Encoded type.
Signature
declare const fromKey: { <Key extends PropertyKey>(key: Key): <TypeToken extends Token, Type, EncodedToken extends Token, Encoded, HasDefault extends boolean, R>(self: PropertySignature<TypeToken, Type, PropertyKey, EncodedToken, Encoded, HasDefault, R>) => PropertySignature<TypeToken, Type, Key, EncodedToken, Encoded, HasDefault, R>; <Type, TypeToken extends Token, Encoded, EncodedToken extends Token, HasDefault extends boolean, R, Key extends PropertyKey>(self: PropertySignature<TypeToken, Type, PropertyKey, EncodedToken, Encoded, HasDefault, R>, key: Key): PropertySignature<TypeToken, Type, Key, EncodedToken, Encoded, HasDefault, R>;}Signature
declare class FromPropertySignature extends OptionalType { constructor(type: AST, isOptional: boolean, isReadonly: boolean, annotations: Annotations, fromKey?: PropertyKey); readonly fromKey?: PropertyKey; readonly isReadonly: boolean;}Signature
declare function makePropertySignature<TypeToken extends Token, Type, Key extends PropertyKey, EncodedToken extends Token, Encoded, HasDefault extends boolean = false, R = never>(ast: AST): PropertySignatureImpl<TypeToken, Type, Key, EncodedToken, Encoded, HasDefault, R>Signature
declare const optional: <S extends All>(self: S) => optional<S>Converts an optional property to another optional property through a transformation Option -> Option.
decode:noneas argument means the value is missing in the input.noneas return value means the value will be missing in the output.
encode:noneas argument means the value is missing in the input.noneas return value means the value will be missing in the output.
Signature
declare function optionalToOptional<FA, FI, FR, TA, TI, TR>(from: Schema<FA, FI, FR>, to: Schema<TA, TI, TR>, options: { readonly decode: (o: Option<FA>) => Option<TI>; readonly encode: (o: Option<TI>) => Option<FA>;}): PropertySignature<"?:", TA, never, "?:", FI, false, FR | TR>Converts an optional property to a required one through a transformation Option -> Type.
decode:noneas argument means the value is missing in the input.encode:noneas return value means the value will be missing in the output.
Signature
declare function optionalToRequired<FA, FI, FR, TA, TI, TR>(from: Schema<FA, FI, FR>, to: Schema<TA, TI, TR>, options: { readonly decode: (o: Option<FA>) => TI; readonly encode: (ti: TI) => Option<FA>;}): PropertySignature<":", TA, never, "?:", FI, false, FR | TR>Signature
declare const optionalWith: { <S extends All, Options extends OptionalOptions<Type<S>>>(options: Options): (self: S) => optionalWith<S, Options>; <S extends All, Options extends OptionalOptions<Type<S>>>(self: S, options: Options): optionalWith<S, Options>;}Lifts a Schema into a PropertySignature.
Signature
declare const propertySignature: <S extends All>(self: S) => propertySignature<S>PropertySignature
interfaceSignature
interface PropertySignature<TypeToken extends PropertySignature.Token, Type, Key extends PropertyKey, EncodedToken extends PropertySignature.Token, Encoded, HasDefault extends boolean = false, R = never> extends Variance<Type, Encoded, R>, Pipeable { readonly _EncodedToken: EncodedToken; readonly _HasDefault: HasDefault; readonly _Key: Key; readonly _TypeToken: TypeToken; readonly [PropertySignatureTypeId]: null; readonly ast: AST; annotations(annotations: Annotations<Type>): PropertySignature<TypeToken, Type, Key, EncodedToken, Encoded, HasDefault, R>;}Signature
declare class PropertySignatureDeclaration extends OptionalType { constructor(type: AST, isOptional: boolean, isReadonly: boolean, annotations: Annotations, defaultValue: () => unknown | undefined); readonly _tag: "PropertySignatureDeclaration"; readonly defaultValue: () => unknown | undefined; readonly isReadonly: boolean; toString(): string;}Signature
declare class PropertySignatureTransformation { constructor(from: FromPropertySignature, to: ToPropertySignature, decode: (o: Option<any>) => Option<any>, encode: (o: Option<any>) => Option<any>); readonly _tag: "PropertySignatureTransformation"; readonly decode: (o: Option<any>) => Option<any>; readonly encode: (o: Option<any>) => Option<any>; readonly from: FromPropertySignature; readonly to: ToPropertySignature; toString(): string;}Converts an optional property to a required one through a transformation Type -> Option.
decode:noneas return value means the value will be missing in the output.encode:noneas argument means the value is missing in the input.
Signature
declare function requiredToOptional<FA, FI, FR, TA, TI, TR>(from: Schema<FA, FI, FR>, to: Schema<TA, TI, TR>, options: { readonly decode: (fa: FA) => Option<TI>; readonly encode: (o: Option<TI>) => FA;}): PropertySignature<"?:", TA, never, ":", FI, false, FR | TR>Signature
declare class ToPropertySignature extends OptionalType { constructor(type: AST, isOptional: boolean, isReadonly: boolean, annotations: Annotations, defaultValue: () => unknown | undefined); readonly defaultValue: () => unknown | undefined; readonly isReadonly: boolean;}Enhances a property signature with a default constructor value.
Signature
declare const withConstructorDefault: { <Type>(defaultValue: () => NoInfer<Type>): <TypeToken extends Token, Key extends PropertyKey, EncodedToken extends Token, Encoded, R>(self: PropertySignature<TypeToken, Type, Key, EncodedToken, Encoded, boolean, R>) => PropertySignature<TypeToken, Type, Key, EncodedToken, Encoded, true, R>; <TypeToken extends Token, Type, Key extends PropertyKey, EncodedToken extends Token, Encoded, R>(self: PropertySignature<TypeToken, Type, Key, EncodedToken, Encoded, boolean, R>, defaultValue: () => NoInfer<Type>): PropertySignature<TypeToken, Type, Key, EncodedToken, Encoded, true, R>;}Enhances a property signature with a default decoding value.
Signature
declare const withDecodingDefault: { <Type>(defaultValue: () => NoInfer<Exclude<Type, undefined>>): <Key extends PropertyKey, Encoded, R>(self: PropertySignature<"?:", Type, Key, "?:", Encoded, false, R>) => PropertySignature<":", Exclude<Type, undefined>, Key, "?:", Encoded, false, R>; <Type, Key extends PropertyKey, Encoded, R>(self: PropertySignature<"?:", Type, Key, "?:", Encoded, false, R>, defaultValue: () => NoInfer<Exclude<Type, undefined>>): PropertySignature<":", Exclude<Type, undefined>, Key, "?:", Encoded, false, R>;}Enhances a property signature with a default decoding value and a default constructor value.
Signature
declare const withDefaults: { <Type>(defaults: { constructor: () => Types.NoInfer<Exclude<Type, undefined>>; decoding: () => Types.NoInfer<Exclude<Type, undefined>>; }): <Key extends PropertyKey, Encoded, R>(self: PropertySignature<"?:", Type, Key, "?:", Encoded, boolean, R>) => PropertySignature<":", Exclude<Type, undefined>, Key, "?:", Encoded, true, R>; <Type, Key extends PropertyKey, Encoded, R>(self: PropertySignature<"?:", Type, Key, "?:", Encoded, boolean, R>, defaults: { constructor: () => Types.NoInfer<Exclude<Type, undefined>>; decoding: () => Types.NoInfer<Exclude<Type, undefined>>; }): PropertySignature<":", Exclude<Type, undefined>, Key, "?:", Encoded, true, R>;}ReadonlyArray Filters
Signature
declare function itemsCount<S extends Any>(n: number, annotations?: Filter<Type<S>, Type<S>>): <A extends readonly Array<any>>(self: S & Schema<A, Encoded<S>, Context<S>>) => filter<S>Signature
declare function maxItems<S extends Any>(n: number, annotations?: Filter<Type<S>, Type<S>>): <A extends readonly Array<any>>(self: S & Schema<A, Encoded<S>, Context<S>>) => filter<S>Signature
declare function minItems<S extends Any>(n: number, annotations?: Filter<Type<S>, Type<S>>): <A extends readonly Array<any>>(self: S & Schema<A, Encoded<S>, Context<S>>) => filter<S>ReadonlyArray Transformations
Signature
declare function getNumberIndexedAccess<A extends readonly Array<any>, I extends readonly Array<any>, R>(self: Schema<A, I, R>): SchemaClass<A[number], I[number], R>Get the first element of a ReadonlyArray, or None if the array is empty.
Signature
declare function head<S extends Any, A extends readonly Array<unknown>>(self: S & Schema<A, Encoded<S>, Context<S>>): transform<S, OptionFromSelf<SchemaClass<A[number], A[number], never>>>Retrieves the first element of a ReadonlyArray.
If the array is empty, it returns the fallback argument if provided; otherwise, it fails.
Signature
declare const headOrElse: { <S extends Any, A extends readonly Array<unknown>>(fallback?: LazyArg<A[number]>): (self: S & Schema<A, Encoded<S>, Context<S>>) => transform<S, SchemaClass<A[number], A[number], never>>; <S extends Any, A extends readonly Array<unknown>>(self: S & Schema<A, Encoded<S>, Context<S>>, fallback?: LazyArg<A[number]>): transform<S, SchemaClass<A[number], A[number], never>>;}ReadonlyMap
Signature
declare const ReadonlyMapFromSelf: <K extends Any, V extends Any>(__namedParameters: { readonly key: K; readonly value: V;}) => ReadonlyMapFromSelf<K, V>ReadonlyMap Transformations
Signature
declare function ReadonlyMap<K extends Any, V extends Any>(__namedParameters: { readonly key: K; readonly value: V;}): ReadonlyMap$<K, V>Signature
declare function ReadonlyMapFromRecord<KA, KR, VA, VI, VR>(__namedParameters: { key: Schema<KA, string, KR>; value: Schema<VA, VI, VR>;}): SchemaClass<ReadonlyMap<KA, VA>, { [x: string]: VI;}, KR | VR>ReadonlySet
Signature
declare const ReadonlySetFromSelf: <Value extends Any>(value: Value) => ReadonlySetFromSelf<Value>ReadonlySet Transformations
Signature
declare function ReadonlySet<Value extends Any>(value: Value): ReadonlySet$<Value>Redacted Constructors
Signature
declare const RedactedFromSelf: <Value extends Any>(value: Value) => RedactedFromSelf<Value>Redacted Transformations
Renaming
Signature
declare const rename: { <A, M extends { [K in string | number | symbol]: PropertyKey } & { [K in string | number | symbol]: never }>(mapping: M): <I, R>(self: Schema<A, I, R>) => SchemaClass<{ [K in string | number | symbol]: Rename<A, M>[K] }, I, R>; <A, I, R, M extends { [K in string | number | symbol]: PropertyKey } & { [K in string | number | symbol]: never }>(self: Schema<A, I, R>, mapping: M): SchemaClass<{ [K in string | number | symbol]: Rename<A, M>[K] }, I, R>;}Schema Id
Signature
declare const BetweenBigDecimalSchemaId: unique symbolSignature
declare const BetweenBigIntSchemaId: unique symbolSignature
type BetweenBigIntSchemaId = typeof BetweenBigIntSchemaIdSignature
declare const BetweenDateSchemaId: unique symbolSignature
declare const BetweenDurationSchemaId: unique symbolSignature
declare const BetweenSchemaId: unique symbolBetweenSchemaId
typeSignature
type BetweenSchemaId = typeof BetweenSchemaIdSignature
declare const BrandSchemaId: unique symbolSignature
declare const CapitalizedSchemaId: unique symbolSignature
declare const DateFromSelfSchemaId: unique symbolDateFromSelfSchemaId
typeSignature
type DateFromSelfSchemaId = typeof DateFromSelfSchemaIdSignature
declare const EndsWithSchemaId: unique symbolSignature
declare const FiniteSchemaId: unique symbolFiniteSchemaId
typeSignature
type FiniteSchemaId = typeof FiniteSchemaIdSignature
declare const GreaterThanBigDecimalSchemaId: unique symbolSignature
declare const GreaterThanBigIntSchemaId: unique symbolSignature
type GreaterThanBigIntSchemaId = typeof GreaterThanBigIntSchemaIdSignature
declare const GreaterThanDateSchemaId: unique symbolSignature
declare const GreaterThanDurationSchemaId: unique symbolSignature
declare const GreaterThanOrEqualToBigDecimalSchemaId: unique symbolSignature
declare const GreaterThanOrEqualToBigIntSchemaId: unique symbolSignature
type GreaterThanOrEqualToBigIntSchemaId = typeof GreaterThanOrEqualToBigIntSchemaIdSignature
declare const GreaterThanOrEqualToDateSchemaId: unique symbolSignature
declare const GreaterThanOrEqualToDurationSchemaId: unique symbolSignature
declare const GreaterThanOrEqualToSchemaId: unique symbolSignature
type GreaterThanOrEqualToSchemaId = typeof GreaterThanOrEqualToSchemaIdSignature
declare const GreaterThanSchemaId: unique symbolGreaterThanSchemaId
typeSignature
type GreaterThanSchemaId = typeof GreaterThanSchemaIdSignature
declare const IncludesSchemaId: unique symbolSignature
declare const InstanceOfSchemaId: unique symbolSignature
declare const IntSchemaId: unique symbolIntSchemaId
typeSignature
type IntSchemaId = typeof IntSchemaIdSignature
declare const ItemsCountSchemaId: unique symbolItemsCountSchemaId
typeSignature
type ItemsCountSchemaId = typeof ItemsCountSchemaIdSignature
declare const JsonNumberSchemaId: unique symbolJsonNumberSchemaId
typeSignature
type JsonNumberSchemaId = typeof JsonNumberSchemaIdSignature
declare const LengthSchemaId: unique symbolLengthSchemaId
typeSignature
type LengthSchemaId = typeof LengthSchemaIdSignature
declare const LessThanBigDecimalSchemaId: unique symbolSignature
declare const LessThanBigIntSchemaId: unique symbolSignature
type LessThanBigIntSchemaId = typeof LessThanBigIntSchemaIdSignature
declare const LessThanDateSchemaId: unique symbolSignature
declare const LessThanDurationSchemaId: unique symbolSignature
declare const LessThanOrEqualToBigDecimalSchemaId: unique symbolSignature
declare const LessThanOrEqualToBigIntSchemaId: unique symbolSignature
type LessThanOrEqualToBigIntSchemaId = typeof LessThanOrEqualToBigIntSchemaIdSignature
declare const LessThanOrEqualToDateSchemaId: unique symbolSignature
declare const LessThanOrEqualToDurationSchemaId: unique symbolSignature
declare const LessThanOrEqualToSchemaId: unique symbolSignature
type LessThanOrEqualToSchemaId = typeof LessThanOrEqualToSchemaIdSignature
declare const LessThanSchemaId: unique symbolLessThanSchemaId
typeSignature
type LessThanSchemaId = typeof LessThanSchemaIdSignature
declare const LowercasedSchemaId: unique symbolSignature
declare const MaxItemsSchemaId: unique symbolMaxItemsSchemaId
typeSignature
type MaxItemsSchemaId = typeof MaxItemsSchemaIdSignature
declare const MaxLengthSchemaId: unique symbolMaxLengthSchemaId
typeSignature
type MaxLengthSchemaId = typeof MaxLengthSchemaIdSignature
declare const MinItemsSchemaId: unique symbolMinItemsSchemaId
typeSignature
type MinItemsSchemaId = typeof MinItemsSchemaIdSignature
declare const MinLengthSchemaId: unique symbolMinLengthSchemaId
typeSignature
type MinLengthSchemaId = typeof MinLengthSchemaIdSignature
declare const MultipleOfSchemaId: unique symbolSignature
declare const NegativeBigDecimalSchemaId: unique symbolSignature
declare const NonNaNSchemaId: unique symbolNonNaNSchemaId
typeSignature
type NonNaNSchemaId = typeof NonNaNSchemaIdSignature
declare const NonNegativeBigDecimalSchemaId: unique symbolSignature
declare const NonPositiveBigDecimalSchemaId: unique symbolSignature
declare const PatternSchemaId: unique symbolSignature
declare const PositiveBigDecimalSchemaId: unique symbolSignature
declare const StartsWithSchemaId: unique symbolSignature
declare const TrimmedSchemaId: unique symbolSignature
declare const ULIDSchemaId: unique symbolSignature
declare const UncapitalizedSchemaId: unique symbolSignature
declare const UppercasedSchemaId: unique symbolSignature
declare const UUIDSchemaId: unique symbolSignature
declare const ValidDateSchemaId: unique symbolSet
Signature
declare const SetFromSelf: <Value extends Any>(value: Value) => SetFromSelf<Value>SortedSet Transformations
Signature
declare function SortedSet<Value extends Any>(value: Value, ordA: Order<Type<Value>>): SortedSet<Value>Signature
declare const SortedSetFromSelf: <Value extends Any>(value: Value, ordA: Order<Type<Value>>, ordI: Order<Encoded<Value>>) => SortedSetFromSelf<Value>Standard Schema
Returns a "Standard Schema" object conforming to the Standard Schema v1 specification.
This function creates a schema whose validate method attempts to decode and
validate the provided input synchronously. If the underlying Schema
includes any asynchronous components (e.g., asynchronous message resolutions
or checks), then validation will necessarily return a Promise instead.
Any detected defects will be reported via a single issue containing no
path.
Signature
declare function standardSchemaV1<A, I>(schema: Schema<A, I, never>, overrideOptions?: ParseOptions): anyExample
import { Schema } from "effect"
const schema = Schema.Struct({ name: Schema.String})
// โโโโ StandardSchemaV1<{ readonly name: string; }>// โผconst standardSchema = Schema.standardSchemaV1(schema)String Constructors
Signature
declare class Capitalized extends Variance<string, string, never, this> { constructor(_: never);}A schema representing a single character.
Signature
declare class Char extends Variance<string, string, never, this> { constructor(_: never);}Signature
declare class Lowercased extends Variance<string, string, never, this> { constructor(_: never);}Signature
declare class NonEmptyString extends Variance<string, string, never, this> { constructor(_: never);}Useful for validating strings that must contain meaningful characters without leading or trailing whitespace.
Signature
declare class NonEmptyTrimmedString extends Variance<string, string, never, this> { constructor(_: never);}Example
import { Schema } from "effect"
console.log(Schema.decodeOption(Schema.NonEmptyTrimmedString)("")) // Option.none()console.log(Schema.decodeOption(Schema.NonEmptyTrimmedString)(" a ")) // Option.none()console.log(Schema.decodeOption(Schema.NonEmptyTrimmedString)("a")) // Option.some("a")Signature
declare class Trimmed extends Variance<string, string, never, this> { constructor(_: never);}Represents a Universally Unique Lexicographically Sortable Identifier (ULID).
ULIDs are designed to be compact, URL-safe, and ordered, making them suitable for use as identifiers. This schema ensures that the provided string adheres to the standard ULID format.
Signature
declare class ULID extends Variance<string, string, never, this> { constructor(_: never);}Signature
declare class Uncapitalized extends Variance<string, string, never, this> { constructor(_: never);}Signature
declare class Uppercased extends Variance<string, string, never, this> { constructor(_: never);}Represents a Universally Unique Identifier (UUID).
This schema ensures that the provided string adheres to the standard UUID format.
Signature
declare class UUID extends Variance<string, string, never, this> { constructor(_: never);}String Filters
Verifies that a string is capitalized.
Signature
declare function capitalized<S extends Any>(annotations?: Filter<Type<S>, Type<S>>): <A extends string>(self: S & Schema<A, Encoded<S>, Context<S>>) => filter<S>Signature
declare function endsWith<S extends Any>(endsWith: string, annotations?: Filter<Type<S>, Type<S>>): <A extends string>(self: S & Schema<A, Encoded<S>, Context<S>>) => filter<S>Signature
declare function includes<S extends Any>(searchString: string, annotations?: Filter<Type<S>, Type<S>>): <A extends string>(self: S & Schema<A, Encoded<S>, Context<S>>) => filter<S>Signature
declare function length<S extends Any>(length: number | { readonly max: number; readonly min: number;}, annotations?: Filter<Type<S>, Type<S>>): <A extends string>(self: S & Schema<A, Encoded<S>, Context<S>>) => filter<S>Verifies that a string is lowercased.
Signature
declare function lowercased<S extends Any>(annotations?: Filter<Type<S>, Type<S>>): <A extends string>(self: S & Schema<A, Encoded<S>, Context<S>>) => filter<S>Signature
declare function maxLength<S extends Any>(maxLength: number, annotations?: Filter<Type<S>, Type<S>>): <A extends string>(self: S & Schema<A, Encoded<S>, Context<S>>) => filter<S>Signature
declare function minLength<S extends Any>(minLength: number, annotations?: Filter<Type<S>, Type<S>>): <A extends string>(self: S & Schema<A, Encoded<S>, Context<S>>) => filter<S>Signature
declare function nonEmptyString<S extends Any>(annotations?: Filter<Type<S>, Type<S>>): <A extends string>(self: S & Schema<A, Encoded<S>, Context<S>>) => filter<S>Signature
declare function pattern<S extends Any>(regex: RegExp, annotations?: Filter<Type<S>, Type<S>>): <A extends string>(self: S & Schema<A, Encoded<S>, Context<S>>) => filter<S>Signature
declare function startsWith<S extends Any>(startsWith: string, annotations?: Filter<Type<S>, Type<S>>): <A extends string>(self: S & Schema<A, Encoded<S>, Context<S>>) => filter<S>Verifies that a string contains no leading or trailing whitespaces.
Note. This combinator does not make any transformations, it only validates.
If what you were looking for was a combinator to trim strings, then check out the trim combinator.
Signature
declare function trimmed<S extends Any>(annotations?: Filter<Type<S>, Type<S>>): <A extends string>(self: S & Schema<A, Encoded<S>, Context<S>>) => filter<S>Verifies that a string is uncapitalized.
Signature
declare function uncapitalized<S extends Any>(annotations?: Filter<Type<S>, Type<S>>): <A extends string>(self: S & Schema<A, Encoded<S>, Context<S>>) => filter<S>Verifies that a string is uppercased.
Signature
declare function uppercased<S extends Any>(annotations?: Filter<Type<S>, Type<S>>): <A extends string>(self: S & Schema<A, Encoded<S>, Context<S>>) => filter<S>String Transformations
This schema converts a string to capitalized one.
Signature
declare class Capitalize extends Variance<string, string, never, this> { constructor(_: never);}This schema converts a string to lowercase.
Signature
declare class Lowercase extends Variance<string, string, never, this> { constructor(_: never);}The ParseJson combinator provides a method to convert JSON strings into the unknown type using the underlying
functionality of JSON.parse. It also utilizes JSON.stringify for encoding.
You can optionally provide a ParseJsonOptions to configure both JSON.parse and JSON.stringify executions.
Optionally, you can pass a schema Schema<A, I, R> to obtain an A type instead of unknown.
Signature
declare const parseJson: { <S extends Any>(schema: S, options?: ParseJsonOptions): transform<SchemaClass<unknown, string, never>, S>; (options?: ParseJsonOptions): SchemaClass<unknown, string>;}Example
import * as assert from "node:assert"import * as Schema from "effect/Schema"
assert.deepStrictEqual(Schema.decodeUnknownSync(Schema.parseJson())(`{"a":"1"}`), { a: "1" })assert.deepStrictEqual(Schema.decodeUnknownSync(Schema.parseJson(Schema.Struct({ a: Schema.NumberFromString })))(`{"a":"1"}`), { a: 1 })Returns a schema that allows splitting a string into an array of strings.
Signature
declare function split(separator: string): transform<SchemaClass<string, string, never>, Array$<typeof String$>>Decodes a base64 (RFC4648) encoded string into a UTF-8 string.
Signature
declare const StringFromBase64: Schema<string>Decodes a base64 (URL) encoded string into a UTF-8 string.
Signature
declare const StringFromBase64Url: Schema<string>Decodes a hex encoded string into a UTF-8 string.
Signature
declare const StringFromHex: Schema<string>Decodes a URI component encoded string into a UTF-8 string. Can be used to store data in a URL.
Signature
declare const StringFromUriComponent: transformOrFail<SchemaClass<string, string, never>, typeof String$, never>Example
import { Schema } from "effect"
const PaginationSchema = Schema.Struct({ maxItemPerPage: Schema.Number, page: Schema.Number})
const UrlSchema = Schema.compose(Schema.StringFromUriComponent, Schema.parseJson(PaginationSchema))
console.log(Schema.encodeSync(UrlSchema)({ maxItemPerPage: 10, page: 1 }))// Output: %7B%22maxItemPerPage%22%3A10%2C%22page%22%3A1%7DThis schema allows removing whitespaces from the beginning and end of a string.
Signature
declare class Trim extends Variance<string, string, never, this> { constructor(_: never);}This schema converts a string to uncapitalized one.
Signature
declare class Uncapitalize extends Variance<string, string, never, this> { constructor(_: never);}This schema converts a string to uppercase.
Signature
declare class Uppercase extends Variance<string, string, never, this> { constructor(_: never);}Struct Transformations
Signature
declare function omit<A, I, Keys extends readonly Array<keyof A & keyof I>>(...keys: Keys): <R>(self: Schema<A, I, R>) => SchemaClass<{ [K in string | number | symbol]: Omit<A, Keys[number]>[K] }, { [K in string | number | symbol]: Omit<I, Keys[number]>[K] }, R>Signature
declare function pick<A, I, Keys extends readonly Array<keyof A & keyof I>>(...keys: Keys): <R>(self: Schema<A, I, R>) => SchemaClass<{ [K in string | number | symbol]: Pick<A, Keys[number]>[K] }, { [K in string | number | symbol]: Pick<I, Keys[number]>[K] }, R>Given a schema Schema<A, I, R> and a key key: K, this function extracts a specific field from the A type,
producing a new schema that represents a transformation from the { readonly [key]: I[K] } type to A[K].
Signature
declare const pluck: { <A, I, K extends string | number | symbol>(key: K): <R>(schema: Schema<A, I, R>) => SchemaClass<A[K], { [K in string | number | symbol]: Pick<I, K>[K] }, R>; <A, I, R, K extends string | number | symbol>(schema: Schema<A, I, R>, key: K): SchemaClass<A[K], { [K in string | number | symbol]: Pick<I, K>[K] }, R>;}Example
import * as Schema from "effect/Schema"
// ---------------------------------------------// use case: pull out a single field from a// struct through a transformation// ---------------------------------------------
const mytable = Schema.Struct({ column1: Schema.NumberFromString, column2: Schema.Number})
// const pullOutColumn: S.Schema<number, {// readonly column1: string;// }, never>const pullOutColumn = mytable.pipe(Schema.pluck("column1"))
console.log(Schema.decodeUnknownEither(Schema.Array(pullOutColumn))([{ column1: "1", column2: 100 }, { column1: "2", column2: 300 }]))// Output: { _id: 'Either', _tag: 'Right', right: [ 1, 2 ] }Symbol
Signature
declare const PropertySignatureTypeId: unique symbolSignature
type PropertySignatureTypeId = typeof PropertySignatureTypeIdSignature
declare const RefineSchemaId: unique symbolRefineSchemaId
typeSignature
type RefineSchemaId = typeof RefineSchemaIdSignature
declare const symbolSerializable: unique symbolSignature
declare const symbolWithResult: unique symbolSignature
declare const TypeId: unique symbolSignature
type TypeId = typeof TypeIdTemplate Literal
Signature
declare const TemplateLiteral: <Params extends readonly [TemplateLiteralParameter, TemplateLiteralParameter]>(...__namedParameters: Params) => TemplateLiteral<GetTemplateLiteralType<Params>>Signature
declare const TemplateLiteralParser: <Params extends readonly [TemplateLiteralParserParameters, TemplateLiteralParserParameters]>(...params: Params) => TemplateLiteralParser<Params>TimeZone Constructors
Signature
declare class TimeZoneFromSelf extends Variance<Offset | Named, Offset | Named, never, this> { constructor(_: never);}Describes a schema that represents a TimeZone.Named instance.
Signature
declare class TimeZoneNamedFromSelf extends Variance<Named, Named, never, this> { constructor(_: never);}Describes a schema that represents a TimeZone.Offset instance.
Signature
declare class TimeZoneOffsetFromSelf extends Variance<Offset, Offset, never, this> { constructor(_: never);}TimeZone Transformations
Defines a schema that attempts to convert a string to a TimeZone using the DateTime.zoneFromString constructor.
Signature
declare class TimeZone extends Variance<Offset | Named, string, never, this> { constructor(_: never);}Defines a schema that attempts to convert a string to a TimeZone.Named instance using the DateTime.zoneUnsafeMakeNamed constructor.
Signature
declare class TimeZoneNamed extends Variance<Named, string, never, this> { constructor(_: never);}Defines a schema that converts a number to a TimeZone.Offset instance using the DateTime.zoneMakeOffset constructor.
Signature
declare class TimeZoneOffset extends Variance<Offset, number, never, this> { constructor(_: never);}Transformations
Signature
declare const filterEffect: { <S extends Any, FD>(f: (a: NoInfer<Type<S>>, options: ParseOptions, self: Transformation) => Effect<FilterReturnType, never, FD>): (self: S) => filterEffect<S, FD>; <S extends Any, RD>(self: S, f: (a: NoInfer<Type<S>>, options: ParseOptions, self: Transformation) => Effect<FilterReturnType, never, RD>): filterEffect<S, RD>;}Create a new Schema by transforming the input and output of an existing Schema
using the provided mapping functions.
Signature
declare const transform: { <To extends Any, From extends Any>(to: To, options: { readonly decode: (fromA: Type<From>, fromI: Encoded<From>) => Encoded<To>; readonly encode: (toI: Encoded<To>, toA: Type<To>) => Type<From>; readonly strict?: true; } | { readonly decode: (fromA: Type<From>, fromI: Encoded<From>) => unknown; readonly encode: (toI: Encoded<To>, toA: Type<To>) => unknown; readonly strict: false; }): (from: From) => transform<From, To>; <To extends Any, From extends Any>(from: From, to: To, options: { readonly decode: (fromA: Type<From>, fromI: Encoded<From>) => Encoded<To>; readonly encode: (toI: Encoded<To>, toA: Type<To>) => Type<From>; readonly strict?: true; } | { readonly decode: (fromA: Type<From>, fromI: Encoded<From>) => unknown; readonly encode: (toI: Encoded<To>, toA: Type<To>) => unknown; readonly strict: false; }): transform<From, To>;}Create a new Schema by transforming the input and output of an existing Schema
using the provided decoding functions.
Signature
declare const transformOrFail: { <To extends Any, From extends Any, RD, RE>(to: To, options: { readonly decode: (fromA: Type<From>, options: ParseOptions, ast: Transformation, fromI: Encoded<From>) => Effect<Encoded<To>, ParseIssue, RD>; readonly encode: (toI: Encoded<To>, options: ParseOptions, ast: Transformation, toA: Type<To>) => Effect<Type<From>, ParseIssue, RE>; readonly strict?: true; } | { readonly decode: (fromA: Type<From>, options: ParseOptions, ast: Transformation, fromI: Encoded<From>) => Effect<unknown, ParseIssue, RD>; readonly encode: (toI: Encoded<To>, options: ParseOptions, ast: Transformation, toA: Type<To>) => Effect<unknown, ParseIssue, RE>; readonly strict: false; }): (from: From) => transformOrFail<From, To, RD | RE>; <To extends Any, From extends Any, RD, RE>(from: From, to: To, options: { readonly decode: (fromA: Type<From>, options: ParseOptions, ast: Transformation, fromI: Encoded<From>) => Effect<Encoded<To>, ParseIssue, RD>; readonly encode: (toI: Encoded<To>, options: ParseOptions, ast: Transformation, toA: Type<To>) => Effect<Type<From>, ParseIssue, RE>; readonly strict?: true; } | { readonly decode: (fromA: Type<From>, options: ParseOptions, ast: Transformation, fromI: Encoded<From>) => Effect<unknown, ParseIssue, RD>; readonly encode: (toI: Encoded<To>, options: ParseOptions, ast: Transformation, toA: Type<To>) => Effect<unknown, ParseIssue, RE>; readonly strict: false; }): transformOrFail<From, To, RD | RE>;}Uint8Array Constructors
Signature
declare class Uint8ArrayFromSelf extends Variance<Uint8Array<ArrayBufferLike>, Uint8Array<ArrayBufferLike>, never, this> { constructor(_: never);}Uint8Array Transformations
Decodes a base64 (RFC4648) encoded string into a Uint8Array.
Signature
declare const Uint8ArrayFromBase64: Schema<Uint8Array, string>Decodes a base64 (URL) encoded string into a Uint8Array.
Signature
declare const Uint8ArrayFromBase64Url: Schema<Uint8Array, string>Decodes a hex encoded string into a Uint8Array.
Signature
declare const Uint8ArrayFromHex: Schema<Uint8Array, string>URL Constructors
Defines a schema that represents a URL object.
Signature
declare class URLFromSelf extends Variance<URL, URL, never, this> { constructor(_: never);}Validation
By default the option exact is set to true.
Signature
declare function asserts<A, I, R>(schema: Schema<A, I, R>, options?: ParseOptions): (u: unknown, overrideOptions?: ParseOptions) => asserts u is ABy default the option exact is set to true.
Signature
declare function is<A, I, R>(schema: Schema<A, I, R>, options?: ParseOptions): (u: unknown, overrideOptions?: number | ParseOptions) => u is ASignature
declare function validate<A, I, R>(schema: Schema<A, I, R>, options?: ParseOptions): (u: unknown, overrideOptions?: ParseOptions) => Effect<A, ParseError, R>Signature
declare function validateEither<A, I, R>(schema: Schema<A, I, R>, options?: ParseOptions): (u: unknown, overrideOptions?: ParseOptions) => Either<A, ParseError>Signature
declare function validateOption<A, I, R>(schema: Schema<A, I, R>, options?: ParseOptions): (u: unknown, overrideOptions?: ParseOptions) => Option<A>Signature
declare function validatePromise<A, I>(schema: Schema<A, I, never>, options?: ParseOptions): (u: unknown, overrideOptions?: ParseOptions) => Promise<A>Signature
declare function validateSync<A, I, R>(schema: Schema<A, I, R>, options?: ParseOptions): (u: unknown, overrideOptions?: ParseOptions) => A