A
arktype4w ago
Simon

Throw an ArkError programmatically

Is there an easy way to throw an ArkError programmatically without defining a schema? I'd like to ensure a provided value is unique against my DB, so I'm looking for an alternative to this:
if (alreadyExists) {
type({ url: type("true").configure({ message: "The URL already exists." }) }).assert(false)
}
if (alreadyExists) {
type({ url: type("true").configure({ message: "The URL already exists." }) }).assert(false)
}
Ideally something simple like
throw new ArkError({ path: ['url'], message: 'The URL already exists." })
throw new ArkError({ path: ['url'], message: 'The URL already exists." })
For context, I'm using this in a tRPC procedure where I already validate the input to check if it's a valid URL.
0 Replies
No replies yetBe the first to reply to this messageJoin

Did you find this page helpful?