2 ms·
You can use `parse` which will throw an exception if the data does not match the schema, or `safeParse` if you want to manually check. > the imperative check f
by shepherdjerred 3y ago
You can use `parse` which will throw an exception if the data does not match the schema, or `safeParse` if you want to manually check.
> the imperative check for `success` seems unfortunate.
Yes! But the cool thing is that `success` being `true` narrows the type and ensures that the `data` field is present. You cannot access `data` without checking for success
Here's another example showing those concepts: https://stackblitz.com/edit/typescript-wbuikz?file=index.ts https://stackblitz.com/edit/typescript-wbuikz?file=index.ts