| 546 | * @since 4.0.0 |
| 547 | */ |
| 548 | export 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`. |