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

Function withExitSuccessDecode

packages/effect/src/encoding/SchemaBinary.ts:5494–5507  ·  view source on GitHub ↗
(target: Schema.Constraint, trusted: Trusted)

Source from the content-addressed store, hash-verified

5492// reporting them, so other success exits keep the schema pass. It is not a
5493// sound `Schema.is` guard, which is why only {@link toCodecDirect} uses it.
5494function withExitSuccessDecode(target: Schema.Constraint, trusted: Trusted): Schema.Constraint {
5495 return Schema.declareConstructor<unknown>()(
5496 [target],
5497 ([codec]) => {
5498 const parse = SchemaParser.decodeUnknownEffect(codec as Schema.ConstraintDecoder<unknown>)
5499 return (input, _ast, options) =>
5500 takeTrusted(trusted, input) ||
5501 (isSuccessExit(input) && options.onExcessProperty !== "error")
5502 ? Effect.succeed(input)
5503 : parse(input, options)
5504 },
5505 { identifier: "binary exit value" }
5506 )
5507}
5508
5509// An exact schema is fully validated by the binary layer in both directions, so
5510// this target adds nothing, except under `onExcessProperty: "error"`.

Callers 1

toCodecDirectFunction · 0.85

Calls 4

takeTrustedFunction · 0.85
isSuccessExitFunction · 0.85
parseFunction · 0.70
succeedMethod · 0.45

Tested by

no test coverage detected