Closed moltar closed 4 years ago
This is certainly possible – but I'm not sure how much utility this adds past the validates
method?
Right now, you can do something like
const data: any = { number: 1 }
if (!parser.validates(data)) {
// throw here
}
// data should be correctly typed here
Closing this for now, but if you have a use case for guard
that validates
doesn't cover, let me know and I'd be happy to add it! (Or, even better, open a PR.)
Would be great to have a method that returns a type guarded object.
Example:
Do you think something like this is possible?