Open
Description
I've found a problem with custom error messages, not sure when it started tho.
Example schema:
const Schema = v.object({
email: v.pipe(
v.string("Whoops! It should be a string."),
v.nonEmpty("Looks like your forgot to tell what is your email."),
v.email("Your email must be valid.")
),
});
Current behavior:
If the object being validate does not have the key, looks like an internal message is returned, while all other options have a "fancy" message.
// message is "Invalid key: Expected \"email\" but received undefined",
const result1 = v.safeParse(Schema, {});
// message is "Whoops! It should be a string."
const result2 = v.safeParse(Schema, { email: undefined });
const result3 = v.safeParse(Schema, { email: null });
const result4 = v.safeParse(Schema, { email: 1 });
Expected output:
All calls should return the same message Whoops! It should be a string.
for the email key.
Reproduction: