Hello I'd like to know how can a I validate a String with spaces, shall I use the match function? Thanks in advance.
You can use the matches function
validator.matches(/^[a-z0-9 ]+$/i);
Here's another alternative?
if (!validator.isAlphanumeric(validator.blacklist(str, ' '))) {
throw new Error('Only a-z,A-Z,0-9');
}
isAlpha(str [, locale, options])
options is an optional object that can be supplied with the following key(s): ignore which can either be a String or RegExp of characters to be ignored e.g. " -" will ignore spaces and -'s.
Most helpful comment
Here's another alternative?