github Effect-TS/effect @effect/schema@0.68.6

latest releases: @effect/sql-sqlite-wasm@0.3.19, @effect/sql-sqlite-bun@0.4.19, @effect/schema@0.68.16...
11 days ago

Patch Changes

  • #3046 530fa9e Thanks @gcanti! - Fix error message display for composite errors when overwrite = false

    This commit resolves an issue where the custom message for a struct (or tuple or union) was displayed regardless of whether the validation error was related to the entire struct or just a specific part of it. Previously, users would see the custom error message even when the error only concerned a particular field within the struct and the flag overwrite was not set to true.

    import { Schema, TreeFormatter } from "@effect/schema";
    import { Either } from "effect";
    
    const schema = Schema.Struct({
      a: Schema.String,
    }).annotations({ message: () => "custom message" });
    
    const res = Schema.decodeUnknownEither(schema)({ a: null });
    if (Either.isLeft(res)) {
      console.log(TreeFormatter.formatErrorSync(res.left));
      // before: custom message
      // now: { readonly a: string }
      //      └─ ["a"]
      //         └─ Expected string, actual null
    }

Don't miss a new effect release

NewReleases is sending notifications on new releases.