decodeUnknownOption is a synchronous decoder that returns an Option value instead of throwing.
Option is an Effect data structure for optional outcomes:
Option.some(value)means decoding succeeded.Option.none()means decoding failed.
Unlike decodeUnknownExit, this function does not return error details. It only tells you whether decoding was a success or failure.
import { Option, Schema } from "effect";
const schema = Schema.Struct({ name: Schema.String, age: Schema.Number,});
const decode = Schema.decodeUnknownOption(schema);
// Happy pathconst ok = decode({ name: "Alice", age: 30 });
if (Option.isSome(ok)) { console.log("Decoded Value:", ok.value);}
// Error pathconst bad = decode({ name: 42, age: "30" }, { errors: "all" });
if (Option.isNone(bad)) { console.log("Decode Result:", "None (invalid input)");}Use decodeUnknownOption when you only care whether decoding succeeded, not why it failed.