cast
Learn about the available options, methods and use cases.
Usage
import e from "validator";
await e.cast(
e.number(),
{} // Optionally pass options
)
.validate("10") // returns 10
// Alternative
await e.deepCast(
e.object({
foo: e.number(),
})
)
.validate('{ "foo": "10" }') // returns { foo: 10 }Options
Last updated