Closed houd1ni closed 1 year ago
Use the coerce option:
const schema = object({
x: coerce(number(), string(), value => +value),
});
console.log(schema.validate({x: '42'}, {coerce: true}));
Thanks! Almost at the same time found it in the code tho 😄 . Obviously, needs some doc improvement for this. @ianstormtaylor
Hi!
I read: https://docs.superstructjs.org/api-reference/coercions#custom-coercions I do:
I have:
What's wrong ? Thanx.