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.
Parameters
Section titled “Parameters”| Parameter | Type | Description |
|---|---|---|
code |
string |
a short name for the reason, such as protected |
message |
string |
the sentence that the person reads |
Returns
Section titled “Returns”{ veto: { code, message } }
Example
Section titled “Example”// rows with the tag #keep cannot be deletedctx.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();});