Patch Changes
-
#4176
39457d4
Thanks @mikearnaldi! - Fix Stream.scoped example -
#4181
a475cc2
Thanks @gcanti! - Schema: FixwithDecodingDefault
implementation to align with its signature (now removesundefined
from the AST).Additionally, a new constraint has been added to the signature to prevent calling
withDecodingDefault
afterwithConstructorDefault
, which previously led to the following issue:import { Schema } from "effect" const schema = Schema.Struct({ a: Schema.optional(Schema.String).pipe( Schema.withConstructorDefault(() => undefined), // this is invalidated by the following call to `withDecodingDefault` Schema.withDecodingDefault(() => "") ) })
-
#4175
199214e
Thanks @gcanti! - Schema: refactor annotations:-
Export internal
Uint8
schema -
Export internal
NonNegativeInt
schema -
Remove title annotations that are identical to identifiers
-
Avoid setting a title annotation when applying branding
-
Add more title annotations to refinements
-
Improve
toString
output and provide more precise error messages for refinements:Before
import { Schema } from "effect" const schema = Schema.Number.pipe( Schema.int({ identifier: "MyInt" }), Schema.positive() ) console.log(String(schema)) // Output: a positive number Schema.decodeUnknownSync(schema)(1.1) /* throws: ParseError: a positive number └─ From side refinement failure └─ MyInt └─ Predicate refinement failure └─ Expected MyInt, actual 1.1 */
After
toString
now combines all refinements with" & "
instead of showing only the last one.- The last message (
"Expected ..."
) now uses the extended description to make the error message clearer.
import { Schema } from "effect" const schema = Schema.Number.pipe( Schema.int({ identifier: "MyInt" }), Schema.positive() ) console.log(String(schema)) // Output: MyInt & positive // <= all the refinements Schema.decodeUnknownSync(schema)(1.1) /* throws: ParseError: MyInt & positive └─ From side refinement failure └─ MyInt └─ Predicate refinement failure └─ Expected an integer, actual 1.1 // <= extended description */
-
-
#4182
b3c160d
Thanks @mikearnaldi! - Replace absolute imports with relative ones