Skip to content

veto

function veto(code, message): Veto;

Stops a change. The person sees message, and whoever made the change is told which plugin refused it.

If your plugin protects data, register the hook with onTimeout: 'veto'. Then the change is also refused when the hook fails or is too slow. Without it, a hook that fails lets the change go through.

Parameter Type Description
code string a short name for the reason, such as protected
message string the sentence that the person reads

Veto

{ veto: { code, message } }

// rows with the tag #keep cannot be deleted
ctx.hooks.shouldDelete({ on: 'row', onTimeout: 'veto' }, delta => {
if (delta.kind !== 'deleted') return allow();
const tags = ctx.facets.core.tags.tags.of({ facets: delta.value.facets ?? {} }) ?? [];
return tags.some(t => t.toLowerCase() === 'keep')
? veto('protected', 'Tagged #keep: it cannot be deleted')
: allow();
});