app/lib/destructive.mjs
17 lines and 1 functions in DrDustinEdwards/dustinedwards-info, at commit 1590ba4 on 2026-10-24. This file on GitHub.
Functions
| Function | Lines | Complexity | Covered | CRAP | Mutation |
|---|---|---|---|---|---|
| confirmationSatisfied | 14 to 17 | 4 | 100% | OkCRAP 4 | No data: no mutants in this code |
Imports
It imports no other module of this repo. Imported by app/components/admin/confirm-dialog.tsx, app/routes/admin.media._index.tsx, app/routes/admin.mentions.tsx, app/routes/admin.posts.$slug.edit.tsx, app/routes/admin.posts._index.tsx.
Source
/*
* A confirmation in a client handler is feedback, not a guard: with script off
* the form posts anyway. The gate is whatever the ACTION checks.
*/
/**
* String-equal on purpose: `Number(typed) === count` would accept "03", "+3",
* "3.0" and "" for zero.
*
* @param {unknown} typed What the operator typed into the confirmation.
* @param {number} count The count read in THIS request, not one the form carried.
* @returns {boolean} Whether the destructive branch may proceed.
*/
export function confirmationSatisfied(typed, count) {
if (!Number.isInteger(count) || count <= 0) return false;
return String(typed ?? "").trim() === String(count);
}
export const CONFIRM_FIELD = "confirm-count";