MCPcopy Index your code
hub / github.com/Effect-TS/effect / requiredToOptional

Function requiredToOptional

packages/effect/src/Schema.ts:2275–2290  ·  view source on GitHub ↗
(
  from: Schema<FA, FI, FR>,
  to: Schema<TA, TI, TR>,
  options: {
    readonly decode: (fa: FA) => option_.Option<TI>
    readonly encode: (o: option_.Option<TI>) => FA
  }
)

Source from the content-addressed store, hash-verified

2273 * @since 3.10.0
2274 */
2275export const requiredToOptional = <FA, FI, FR, TA, TI, TR>(
2276 from: Schema<FA, FI, FR>,
2277 to: Schema<TA, TI, TR>,
2278 options: {
2279 readonly decode: (fa: FA) => option_.Option<TI>
2280 readonly encode: (o: option_.Option<TI>) => FA
2281 }
2282): PropertySignature<"?:", TA, never, ":", FI, false, FR | TR> =>
2283 makePropertySignature(
2284 new PropertySignatureTransformation(
2285 new FromPropertySignature(from.ast, false, true, {}, undefined),
2286 new ToPropertySignature(to.ast, true, true, {}, undefined),
2287 option_.flatMap(options.decode),
2288 (o) => option_.some(options.encode(o))
2289 )
2290 )
2291
2292/**
2293 * Converts an optional property to another optional property through a transformation `Option -> Option`.

Callers

nothing calls this directly

Calls 2

makePropertySignatureFunction · 0.85
encodeMethod · 0.80

Tested by

no test coverage detected