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

Function schemaJsonField

packages/effect/src/unstable/http/UrlParams.ts:548–561  ·  view source on GitHub ↗
(field: string)

Source from the content-addressed store, hash-verified

546 * @since 4.0.0
547 */
548export const schemaJsonField = (field: string): schemaJsonField =>
549 UrlParamsSchema.pipe(
550 Schema.decodeTo(
551 Schema.UnknownFromJsonString,
552 SchemaTransformation.transformOrFail({
553 decode: (params) =>
554 Option.match(getFirst(params, field), {
555 onNone: () => Effect.fail(new SchemaIssue.Pointer([field], new SchemaIssue.MissingKey(undefined))),
556 onSome: Effect.succeed
557 }),
558 encode: (value) => Effect.succeed(make([[field, value]]))
559 })
560 )
561 )
562
563/**
564 * Extract a record of key-value pairs from the `UrlParams`.

Callers

nothing calls this directly

Calls 4

makeFunction · 0.70
pipeMethod · 0.65
failMethod · 0.45
succeedMethod · 0.45

Tested by

no test coverage detected