Dear community,
I’m currently trying to throw a validation error from a custom hook in Directus, and I came across this GitHub thread that provides an example of how it was done in previous versions:
module.exports = function registerHooks({ filter }, { exceptions }) {
filter('test.items.create', async (input) => {
if (!input.name) {
throw new exceptions.FailedValidationException({
message: 'Missing name',
path: ['name'],
type: 'custom.name.invalid',
context: {
invalids: [''],
},
});
However, since Directus v10 changed how errors are handled in extensions, this approach no longer seems to work.
Does anyone know if it’s still possible to throw a validation error using the current @directus/errors package? If so, could you share an example or point me in the right direction?
Thanks in advance!
Deborah