status page validation

This commit is contained in:
Alex Holliday committed 2026-03-02 19:25:34 +00:00
1 parent 8236b02034
commit 16cf23baf1
6 files changed
+70 -81

No files matched your search

+10
View File
@@ -29,6 +29,16 @@ export const lowercaseEmailValidation = z
message: "Email must be in lowercase",
});
/**
* Helper to properly coerce boolean from strings (handles "true"/"false" strings)
* Needed for query parameters and form data where Express sends strings
*/
export const booleanCoercion = z.preprocess((val) => {
if (val === "true" || val === true) return true;
if (val === "false" || val === false) return false;
return val; // Let Zod validation handle invalid values
}, z.boolean());
/**
* Custom validator for role-based authorization
*/