status page validation
This commit is contained in:
1 parent
8236b02034
commit
16cf23baf1
6 files changed
+70
-81
No files matched your search
@@ -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
|
||||
*/
|
||||
|
||||
Reference in new issue
Block a user