Add dynamic route matching and validation improvements
Introduces dynamic route parameter support in route path computation and schema matching. Adds a utility for sending validation errors, updates schema definitions to support header validation, and refactors server middleware to handle header, body, and query validation with improved error handling. Also adds a placeholder user route and updates dependencies to include 'path-to-regexp'.
This commit is contained in:
@@ -1,9 +1,14 @@
|
||||
const z = require("zod")
|
||||
|
||||
module.exports = {
|
||||
errorFormat: "default",
|
||||
POST: {
|
||||
zod: z.object({
|
||||
headers: z.object({
|
||||
authorization: z.string()
|
||||
.startsWith("Bearer ", { message: "Token d'authentification manquant ou invalide." })
|
||||
.optional(),
|
||||
"content-type": z.string().regex(/application\/json/i).optional()
|
||||
}),
|
||||
body: z.object({
|
||||
email: z.string()
|
||||
.email({ message: "Invalid E-Mail format." })
|
||||
.toLowerCase(),
|
||||
@@ -17,7 +22,7 @@ module.exports = {
|
||||
}),
|
||||
error: {
|
||||
code: 422,
|
||||
message: "Invalid body request"
|
||||
message: "Invalid request data"
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user