Patch Changes
-
#4567
c65d336
Thanks @rehos! - Schema:standardSchemaV1
now returns all errors by default and supports custom options.The
standardSchemaV1
now returns all validation errors by default (ParseOptions = { errors: "all" }
). Additionally, it now accepts an optionaloverrideOptions
parameter, allowing you to customize the default parsing behavior as needed. -
#4565
22d2ebb
Thanks @gcanti! - ParseResult.ArrayFormatter: correct_tag
fields forRefinement
andTransformation
issues, closes #4564.This update fixes an issue where
ParseResult.ArrayFormatter
incorrectly labeled Refinement and Transformation errors asType
in the output.Before
import { Effect, ParseResult, Schema } from "effect" const schema = Schema.Struct({ a: Schema.NonEmptyString, b: Schema.NumberFromString }) const input = { a: "", b: "" } const program = Schema.decodeUnknown(schema, { errors: "all" })(input).pipe( Effect.catchTag("ParseError", (err) => ParseResult.ArrayFormatter.formatError(err).pipe( Effect.map((err) => JSON.stringify(err, null, 2)) ) ) ) program.pipe(Effect.runPromise).then(console.log) /* [ { "_tag": "Type", ❌ "path": [ "a" ], "message": "Expected a non empty string, actual \"\"" }, { "_tag": "Type", ❌ "path": [ "b" ], "message": "Unable to decode \"\" into a number" } ] */
After
import { Effect, ParseResult, Schema } from "effect" const schema = Schema.Struct({ a: Schema.NonEmptyString, b: Schema.NumberFromString }) const input = { a: "", b: "" } const program = Schema.decodeUnknown(schema, { errors: "all" })(input).pipe( Effect.catchTag("ParseError", (err) => ParseResult.ArrayFormatter.formatError(err).pipe( Effect.map((err) => JSON.stringify(err, null, 2)) ) ) ) program.pipe(Effect.runPromise).then(console.log) /* [ { "_tag": "Refinement", ✅ "path": [ "a" ], "message": "Expected a non empty string, actual \"\"" }, { "_tag": "Transformation", ✅ "path": [ "b" ], "message": "Unable to decode \"\" into a number" } ] */