Closed karan closed 10 years ago
Try:
var nameValidator = [validate({message: "Username should be between 4 and 30 characters."}, 'regex', /^[a-zA-Z\-]+$/];
Works for me! Might be worth adding a regex example to the README as the syntax (no enclosing quotes) is not always obvious
Will do...
How do I check something in a regex?
Say I am checking a username for A-Z, a-z, 0-9, -, then what I tried didn't work:
And in my code, I have validators in 3 places (on top, then
required
, and then mongoose validation middleware):I am a noob to this, and willing to learn. How do I make my code shorter, or at least easier to read, write and maintain?