Patch Changes
-
#2997
3b15e1b
Thanks @gcanti! - Improve error handling (type-level) for improper usage ofoptional
, closes #2995This commit addresses concerns raised by users about the confusing behavior when 'optional' is misused in a schema definition. Previously, users experienced unexpected results, such as a schema returning 'Schema.All' when 'optional' was used incorrectly, without clear guidance on the correct usage or error messages.
Changes:
- Enhanced the 'optional' method to return a descriptive type-level error when used incorrectly, helping users identify and correct their schema definitions.
- Updated the
Schema.optional()
implementation to check its context within a pipeline and ensure it is being used correctly. - Added unit tests to verify that the new error handling works as expected and to ensure that correct usage does not affect existing functionality.
-
#2994
3a750b2
Thanks @gcanti! - Exposeexact
option for strict decoding on missing properties, closes #2993This commit addresses an issue where users encountered unexpected decoding behaviors, specifically regarding how undefined values and missing properties are handled. The default behavior of the
@effect/schema
library treats missing properties asundefined
during decoding, which can lead to confusion when stricter validation is expected.Changes:
- Exposed an internal configuration option
exțact
(default:false
), which when set totrue
, enforces strict decoding that will error on missing properties instead of treating them asundefined
. - Updated documentation to clearly outline the default and strict decoding behaviors, providing users with guidance on how to enable strict validation.
- Exposed an internal configuration option
-
Updated dependencies [
06ede85
,7204ca5
]:- effect@3.3.3