arktypea
arktype8mo 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)
}


Ideally something simple like
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.
Was this page helpful?