Closed GravlLift closed 2 months ago
Describe the bug If an object's property is listed defined, but the object itself is notRequired, the property will fail validation even when an undefined is passed for the object.
defined
notRequired
To Reproduce
https://codesandbox.io/p/sandbox/mystifying-resonance-hhy8k6?file=%2Fsrc%2Findex.test.js%3A11%2C1
Expected behavior No validation error should be thrown for child properties when the parent object does not exist.
Platform (please complete the following information):
Additional context Basically I'm looking to validate something with this type:
type ObjectType = { property: string; } | null | undefined
and it's throwing for property if the object is undefined, even though the InferType produces the correct type.
property
undefined
InferType
See the section "object defaults" in the docs under the object schema.
Describe the bug If an object's property is listed
defined
, but the object itself isnotRequired
, the property will fail validation even when an undefined is passed for the object.To Reproduce
https://codesandbox.io/p/sandbox/mystifying-resonance-hhy8k6?file=%2Fsrc%2Findex.test.js%3A11%2C1
Expected behavior No validation error should be thrown for child properties when the parent object does not exist.
Platform (please complete the following information):
Additional context Basically I'm looking to validate something with this type:
and it's throwing for
property
if the object isundefined
, even though theInferType
produces the correct type.