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

latest releases: @effect/sql-sqlite-wasm@0.21.1, @effect/sql-sqlite-bun@0.21.8, @effect/sql-libsql@0.9.8...
7 months ago

Patch Changes

  • #2471 58f66fe Thanks @gcanti! - Class API: Added default title annotation to the encoded side.

    Before:

    import * as S from "@effect/schema/Schema";
    
    class MySchema extends S.Class<MySchema>("MySchema")({
      a: S.string,
      b: S.number,
    }) {}
    
    S.decodeUnknownSync(MySchema)({}, { errors: "all" });
    /*
    Error: ({ a: string; b: number } <-> MySchema)
    └─ Encoded side transformation failure
       └─ { a: string; b: number }
          ├─ ["a"]
          │  └─ is missing
          └─ ["b"]
             └─ is missing
    */

    After:

    import * as S from "@effect/schema/Schema";
    
    class MySchema extends S.Class<MySchema>("MySchema")({
      a: S.string,
      b: S.number,
    }) {}
    
    S.decodeUnknownSync(MySchema)({}, { errors: "all" });
    /*
    Error: (MySchema (Encoded side) <-> MySchema)
    └─ Encoded side transformation failure
       └─ MySchema (Encoded side)
          ├─ ["a"]
          │  └─ is missing
          └─ ["b"]
             └─ is missing
    */
  • #2465 3cad21d Thanks @gcanti! - length now allows expressing a range

    Example

    import * as S from "@effect/schema/Schema";
    
    const schema = S.string.pipe(
      S.length({ min: 2, max: 4 }, { identifier: "MyRange" }),
    );
    
    S.decodeUnknownSync(schema)("");
    /*
    throws:
    Error: MyRange
    └─ Predicate refinement failure
       └─ Expected MyRange (a string at least 2 character(s) and at most 4 character(s) long), actual ""
    */
  • Updated dependencies [dadc690]:

    • effect@2.4.18

Don't miss a new effect release

NewReleases is sending notifications on new releases.