diff --git a/backend/src/middleware/validators.js b/backend/src/middleware/validators.js index 884fdfd..bc951aa 100644 --- a/backend/src/middleware/validators.js +++ b/backend/src/middleware/validators.js @@ -70,9 +70,10 @@ const registerValidation = [ .matches(/^[a-zA-ZÀ-ÿ\s'-]+$/) .withMessage('Last name contains invalid characters'), body('wsdcId') - .optional() - .trim() - .matches(/^\d{1,10}$/) + .optional({ nullable: true, checkFalsy: true }) + .isLength({ min: 1, max: 10 }) + .withMessage('WSDC ID must be between 1 and 10 characters') + .matches(/^\d+$/) .withMessage('WSDC ID must be numeric (max 10 digits)'), // Turnstile CAPTCHA (only required if TURNSTILE_SECRET_KEY is set) ...(process.env.TURNSTILE_SECRET_KEY