Auto throw if invalid
I have been looking through the docs and the API manually, but I haven't found something elegant that I am looking for.
Is there a way to strictly throw an error if the validation doesn't pass? While I don't normally mind the explicitness of
instanceof type.errors
, I kinda prefer the method opt-in from Zod (parse vs safeParse) to make that choice. To be clear this would purely be a DX improvement to prevent typing out the error catching manually for type inference.8 Replies
And forgive me if I missed something obivious here
i see the onFail configuration but that appears to be global and effect all validations instead of a safe/strict method opt-in
.assert
ah dang thats it. fwiw
.assert()
doesn't seem to appear in the docs. nor anything based on my original question. maybe something worth updating/adding in the docs. appreciate the help @TravisIt's mentioned within https://arktype.io/docs/type-api
But yeah, could be clearer I suppose
You are right, thank you for pointing it out. search doesn't seem to catch it though. maybe tables are omitted from search?