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

Function schemaJson

packages/platform/src/UrlParams.ts:286–300  ·  view source on GitHub ↗
(schema: Schema.Schema<A, I, R>, options?: ParseOptions | undefined)

Source from the content-addressed store, hash-verified

284 * @category schema
285 */
286export const schemaJson = <A, I, R>(schema: Schema.Schema<A, I, R>, options?: ParseOptions | undefined): {
287 (
288 field: string
289 ): (self: UrlParams) => Effect.Effect<A, ParseResult.ParseError, R>
290 (
291 self: UrlParams,
292 field: string
293 ): Effect.Effect<A, ParseResult.ParseError, R>
294} => {
295 const parse = Schema.decodeUnknown(Schema.parseJson(schema), options)
296 return dual<
297 (field: string) => (self: UrlParams) => Effect.Effect<A, ParseResult.ParseError, R>,
298 (self: UrlParams, field: string) => Effect.Effect<A, ParseResult.ParseError, R>
299 >(2, (self, field) => parse(Option.getOrElse(getLast(self, field), () => "")))
300}
301
302/**
303 * Extract schema from all key-value pairs in the given `UrlParams`.

Callers

nothing calls this directly

Calls 1

parseFunction · 0.50

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…