| 383 | * @since 4.0.0 |
| 384 | */ |
| 385 | export 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 |