fix(validators): correct WSDC ID optional field validation
Fixed validation issue where empty/null wsdcId was incorrectly validated.
Changed from `.optional()` to `.optional({ nullable: true, checkFalsy: true })`
to properly skip validation for falsy values (null, undefined, empty string).
This allows users to register without WSDC ID without triggering
"WSDC ID must be numeric" validation error.
This commit is contained in:
@@ -70,9 +70,10 @@ const registerValidation = [
|
|||||||
.matches(/^[a-zA-ZÀ-ÿ\s'-]+$/)
|
.matches(/^[a-zA-ZÀ-ÿ\s'-]+$/)
|
||||||
.withMessage('Last name contains invalid characters'),
|
.withMessage('Last name contains invalid characters'),
|
||||||
body('wsdcId')
|
body('wsdcId')
|
||||||
.optional()
|
.optional({ nullable: true, checkFalsy: true })
|
||||||
.trim()
|
.isLength({ min: 1, max: 10 })
|
||||||
.matches(/^\d{1,10}$/)
|
.withMessage('WSDC ID must be between 1 and 10 characters')
|
||||||
|
.matches(/^\d+$/)
|
||||||
.withMessage('WSDC ID must be numeric (max 10 digits)'),
|
.withMessage('WSDC ID must be numeric (max 10 digits)'),
|
||||||
// Turnstile CAPTCHA (only required if TURNSTILE_SECRET_KEY is set)
|
// Turnstile CAPTCHA (only required if TURNSTILE_SECRET_KEY is set)
|
||||||
...(process.env.TURNSTILE_SECRET_KEY
|
...(process.env.TURNSTILE_SECRET_KEY
|
||||||
|
|||||||
Reference in New Issue
Block a user