<S extends Constraint>(schema: S): Optic_.Iso<S["Type"], S["Iso"]>Derives an Iso optic from a schema that isomorphically converts between
the schema's Type and its Iso (intermediate / serialized form).
export function function toIso<S extends Constraint>(
schema: S
): Optic_.Iso<S["Type"], S["Iso"]>
Derives an Iso optic from a schema that isomorphically converts between
the schema's Type and its Iso (intermediate / serialized form).
toIso<function (type parameter) S in toIso<S extends Constraint>(schema: S): Optic_.Iso<S["Type"], S["Iso"]>S extends Constraint>(schema: S extends Constraintschema: function (type parameter) S in toIso<S extends Constraint>(schema: S): Optic_.Iso<S["Type"], S["Iso"]>S): import Optic_Optic_.type Optic_.Iso = /*unresolved*/ anyIso<function (type parameter) S in toIso<S extends Constraint>(schema: S): Optic_.Iso<S["Type"], S["Iso"]>S["Type"], function (type parameter) S in toIso<S extends Constraint>(schema: S): Optic_.Iso<S["Type"], S["Iso"]>S["Iso"]> {
const const serializer: Codec<
S["Type"],
S["Iso"],
never,
never
>
const serializer: {
Encoded: E;
DecodingServices: RD;
EncodingServices: RE;
Rebuild: Codec<T, E, RD, RE>;
Type: T;
Iso: Iso;
ast: Ast;
annotate: (annotations: Annotations.Bottom<S['Type'], any>) => Codec<S['Type'], S['Iso'], never, never>;
annotateKey: (annotations: Annotations.Key<S['Type']>) => Codec<S['Type'], S['Iso'], never, never>;
check: (checks_0: SchemaAST.Check<S['Type']>, ...checks: Array<SchemaAST.Check<S['Type']>>) => Codec<S['Type'], S['Iso'], never, never>;
rebuild: (ast: SchemaAST.AST) => Codec<S['Type'], S['Iso'], never, never>;
make: (input: unknown, options?: MakeOptions) => S['Type'];
makeOption: (input: unknown, options?: MakeOptions) => Option_.Option<S['Type']>;
makeEffect: (input: unknown, options?: MakeOptions) => Effect.Effect<S['Type'], SchemaError, never>;
pipe: { <A>(this: A): A; <A, B = never>(this: A, ab: (_: A) => B): B; <A, B = never, C = never>(this: A, ab: (_: A) => B, bc: (_: B) => C): C; <A, B = never, C = never, D = never>(this: A, ab: (_: A) => B, bc: (_: B) => C, cd: (_: C) => D): D; <…;
}
serializer = function toCodecIso<S extends Constraint>(
schema: S
): Codec<S["Type"], S["Iso"]>
Derives an isomorphism codec from a schema. The encoded form is the
schema's Iso type — the intermediate representation used for round-tripping.
toCodecIso(schema: S extends Constraintschema)
return import Optic_Optic_.makeIso(import SchemaParserSchemaParser.const encodeSync: <
S extends Schema.ConstraintEncoder<unknown>
>(
schema: S,
options?: SchemaAST.ParseOptions
) => (
input: S["Type"],
options?: SchemaAST.ParseOptions
) => S["Encoded"]
Creates a synchronous encoder for input already typed as the schema's decoded
Type.
When to use
Use to encode already typed schema values synchronously when encoding failure
should throw an Error whose cause is SchemaIssue.Issue.
Details
The returned function returns the schema's Encoded value on success and throws
an Error with the SchemaIssue.Issue in its cause on encoding failure.
Gotchas
Causes that contain defects, interruptions, or asynchronous work at this
synchronous boundary throw an Error whose cause is the underlying Cause,
instead of being converted to a schema validation error.
encodeSync(const serializer: Codec<
S["Type"],
S["Iso"],
never,
never
>
const serializer: {
Encoded: E;
DecodingServices: RD;
EncodingServices: RE;
Rebuild: Codec<T, E, RD, RE>;
Type: T;
Iso: Iso;
ast: Ast;
annotate: (annotations: Annotations.Bottom<S['Type'], any>) => Codec<S['Type'], S['Iso'], never, never>;
annotateKey: (annotations: Annotations.Key<S['Type']>) => Codec<S['Type'], S['Iso'], never, never>;
check: (checks_0: SchemaAST.Check<S['Type']>, ...checks: Array<SchemaAST.Check<S['Type']>>) => Codec<S['Type'], S['Iso'], never, never>;
rebuild: (ast: SchemaAST.AST) => Codec<S['Type'], S['Iso'], never, never>;
make: (input: unknown, options?: MakeOptions) => S['Type'];
makeOption: (input: unknown, options?: MakeOptions) => Option_.Option<S['Type']>;
makeEffect: (input: unknown, options?: MakeOptions) => Effect.Effect<S['Type'], SchemaError, never>;
pipe: { <A>(this: A): A; <A, B = never>(this: A, ab: (_: A) => B): B; <A, B = never, C = never>(this: A, ab: (_: A) => B, bc: (_: B) => C): C; <A, B = never, C = never, D = never>(this: A, ab: (_: A) => B, bc: (_: B) => C, cd: (_: C) => D): D; <…;
}
serializer), import SchemaParserSchemaParser.const decodeSync: <
S extends Schema.ConstraintDecoder<unknown>
>(
schema: S,
options?: SchemaAST.ParseOptions
) => (
input: S["Encoded"],
options?: SchemaAST.ParseOptions
) => S["Type"]
Creates a synchronous decoder for input already typed as the schema's Encoded
type.
When to use
Use to decode values already typed as the schema's Encoded input when
decoding failure should throw an Error whose cause is SchemaIssue.Issue.
Details
The returned function returns the decoded Type on success and throws an
Error with the SchemaIssue.Issue in its cause on decoding failure.
Gotchas
Causes that contain defects, interruptions, or asynchronous work at this
synchronous boundary throw an Error whose cause is the underlying Cause,
instead of being converted to a schema validation error.
decodeSync(const serializer: Codec<
S["Type"],
S["Iso"],
never,
never
>
const serializer: {
Encoded: E;
DecodingServices: RD;
EncodingServices: RE;
Rebuild: Codec<T, E, RD, RE>;
Type: T;
Iso: Iso;
ast: Ast;
annotate: (annotations: Annotations.Bottom<S['Type'], any>) => Codec<S['Type'], S['Iso'], never, never>;
annotateKey: (annotations: Annotations.Key<S['Type']>) => Codec<S['Type'], S['Iso'], never, never>;
check: (checks_0: SchemaAST.Check<S['Type']>, ...checks: Array<SchemaAST.Check<S['Type']>>) => Codec<S['Type'], S['Iso'], never, never>;
rebuild: (ast: SchemaAST.AST) => Codec<S['Type'], S['Iso'], never, never>;
make: (input: unknown, options?: MakeOptions) => S['Type'];
makeOption: (input: unknown, options?: MakeOptions) => Option_.Option<S['Type']>;
makeEffect: (input: unknown, options?: MakeOptions) => Effect.Effect<S['Type'], SchemaError, never>;
pipe: { <A>(this: A): A; <A, B = never>(this: A, ab: (_: A) => B): B; <A, B = never, C = never>(this: A, ab: (_: A) => B, bc: (_: B) => C): C; <A, B = never, C = never, D = never>(this: A, ab: (_: A) => B, bc: (_: B) => C, cd: (_: C) => D): D; <…;
}
serializer))
}