Spaces:
Paused
Paused
| ; | |
| Object.defineProperty(exports, "__esModule", { value: true }); | |
| const zod_1 = require("zod"); | |
| const pingMessageSchema = zod_1.z.object({ | |
| message: zod_1.z | |
| .string() | |
| .min(1, "Message is required and must be a non-empty string"), | |
| numbers: zod_1.z | |
| .array(zod_1.z | |
| .string() | |
| .min(12, "Each number must be at least 12 characters long") | |
| .regex(/^\d{12}$/, "Invalid phone number format. Correct example: 123456789012")) | |
| .max(5, "You can provide a maximum of 5 phone numbers"), | |
| image: zod_1.z.string().optional() | |
| }); | |
| const validatePingMessage = (req, res, next) => { | |
| try { | |
| pingMessageSchema.parse(req.body); | |
| next(); | |
| } | |
| catch (error) { | |
| if (error instanceof zod_1.z.ZodError) { | |
| res.status(400).json({ errors: error.errors }); | |
| } | |
| else { | |
| res.status(500).json({ message: "Internal Server Error" }); | |
| } | |
| } | |
| }; | |
| exports.default = validatePingMessage; | |