I am planning to make partnerid field character length as 5 which means user will get error message if he enters less than 5 character or more than 5 characters which will include alpha-numeric character. How can we do it using express-validator? I tried using below code but it didn't worked Thanks
req.checkBody('partnerid', 'Partnerid field must be 5 character long ').len(5);
You can use isLength()
option of the express-validator
to check max
and min
length of 5
:
req.checkBody('partnerid', 'Partnerid field must be 5 character long ').isLength({ min: 5, max:5 });