github Effect-TS/effect effect@3.13.8

latest releases: @effect/sql-kysely@0.27.1, @effect/typeclass@0.32.8, @effect/sql@0.31.1...
21 hours ago

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 optional overrideOptions parameter, allowing you to customize the default parsing behavior as needed.

  • #4565 22d2ebb Thanks @gcanti! - ParseResult.ArrayFormatter: correct _tag fields for Refinement and Transformation issues, closes #4564.

    This update fixes an issue where ParseResult.ArrayFormatter incorrectly labeled Refinement and Transformation errors as Type 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"
      }
    ]
    */

Don't miss a new effect release

NewReleases is sending notifications on new releases.