MCPcopy Create free account
hub / github.com/Effect-TS/effect / makeOption

Function makeOption

packages/effect/src/SchemaParser.ts:73–83  ·  view source on GitHub ↗
(schema: S)

Source from the content-addressed store, hash-verified

71 * @since 4.0.0
72 */
73export function makeOption<S extends Schema.Constraint>(schema: S) {
74 const parser = makeEffect(schema)
75 return (input: S["~type.make.in"], options?: Schema.MakeOptions): Option.Option<S["Type"]> => {
76 const exit = Effect.runSyncExit(parser(input, options))
77 if (Exit.isSuccess(exit)) {
78 return Option.some(exit.value)
79 }
80 InternalSchemaCause.getSchemaIssueOrThrow(exit.cause, "Option adapter can only return none for schema issues")
81 return Option.none()
82 }
83}
84
85/**
86 * Creates a synchronous maker for the schema's decoded type side.

Callers

nothing calls this directly

Calls 2

someMethod · 0.80
makeEffectFunction · 0.70

Tested by

no test coverage detected