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

Function schemaJson

packages/effect/src/unstable/http/Multipart.ts:385–400  ·  view source on GitHub ↗
(schema: Schema.ConstraintDecoder<A, RD>, options?: ParseOptions | undefined)

Source from the content-addressed store, hash-verified

383 * @since 4.0.0
384 */
385export const schemaJson = <A, RD>(schema: Schema.ConstraintDecoder<A, RD>, options?: ParseOptions | undefined): {
386 (
387 field: string
388 ): (persisted: Persisted) => Effect.Effect<A, Schema.SchemaError, RD>
389 (
390 persisted: Persisted,
391 field: string
392 ): Effect.Effect<A, Schema.SchemaError, RD>
393} => {
394 const fromJson = Schema.fromJsonString(schema)
395 return dual(2, (persisted: Persisted, field: string): Effect.Effect<A, Schema.SchemaError, RD> =>
396 Effect.map(
397 Schema.decodeUnknownEffect(Schema.Struct({ [field]: fromJson }))(persisted, options),
398 (_) => _[field]
399 ))
400}
401
402/**
403 * Builds the low-level multipart parser configuration from request headers and

Callers

nothing calls this directly

Calls 1

mapMethod · 0.45

Tested by

no test coverage detected