How to use the isMobilePhone function from validator
Find comprehensive JavaScript validator.isMobilePhone code examples handpicked from public code repositorys.
GitHub: justinsisley/marshall
![justinsisley profile picture](/justinsisley.png?size=40)
239 240 241 242 243 244 245 246 247 248
case 'ip': isValid = validator.isIP(stringValue); break; case 'phone': isValid = validator.isMobilePhone(stringValue, this.locale || 'en-US'); break; case 'number': isValid = validator.isNumeric(stringValue);
+ 31 other calls in file
167 168 169 170 171 172 173 174 175 176
} return true; }, isMobilePhone: function(rule, value) { if (rule) { return validator.isMobilePhone(value); } return true; }, isMultibyte: function(rule, value) {
+ 5 other calls in file
GitHub: mboraski/HastyMobile
14 15 16 17 18 19 20 21 22
return isAlpha ? sanitizedName : ''; }; export const sanitizeAndValidatePhoneNumber = dirtyPhoneNumber => { const sanitizedPhoneNumber = validator.escape(dirtyPhoneNumber); const isPhoneNumber = validator.isMobilePhone(sanitizedPhoneNumber); return isPhoneNumber ? sanitizedPhoneNumber : ''; };
12 13 14 15 16 17 18 19 20 21
validator.isAlphanumeric(data.userName) && validator.isLength(data.userName, { min: 3, max: 16 }) && validator.isStrongPassword(data.password) && validator.isAlphanumeric(data.name) && validator.isLength(data.name, { min: 3, max: 16 }) && validator.isMobilePhone(data.phone, "vi-VN") ) { await Customer.findOne({ userName: data.userName }) .then(async (user) => { if (user) {
9 10 11 12 13 14 15 16 17 18
//SIGN UP exports.signUp = (req, res, next) => { console.log(req.body) let validEmail = validator.isEmail(req.body.email); let validPass = validator.isStrongPassword(req.body.password); let validPhone = validator.isMobilePhone(req.body.phone, ['ar-EG']); // if (validEmail && validPass && validPhone) { // console.log(req.body) User.findOne({ email: req.body.email }) .then(user => {
GitHub: AvinashSurin/TO-DO_LIST
91 92 93 94 95 96 97 98 99 100
// validate the input if (validator.isEmail(profile.email, { allow_display_name: true }) // allow_display_name allows us to receive input as: // Display Name <email-address> // which we consider valid too && validator.isMobilePhone(profile.phone, 'he-IL') && validator.isAscii(profile.firstname) && validator.isAscii(profile.lastname) && validator.isAscii(profile.country) ) {
+ 3 other calls in file
45 46 47 48 49 50 51 52 53 54
emergencyContactNumber: { type: String, required: [true, 'please provide a emergency contact number'], validate: { validator: (value) => validator.isMobilePhone(value) }, message: 'please provide a valid phone number' },
280 281 282 283 284 285 286 287 288 289 290
console.log(input + " is a phone array: " + (isArray)) return isArray; } function validatePhone(input){ var isPhone = validator.isMobilePhone(input, ['en-US']); console.log(input + " is a phone: " + (isPhone)) return isPhone; }
15 16 17 18 19 20 21 22 23 24 25 26
return validator.isAlpha(name) && validator.isLength(name, { min: 2 }); } // Validate phone number exports.validatePhone = (phone) => { return validator.isMobilePhone(phone); } // Validate date
192 193 194 195 196 197 198 199 200 201
'mimetype': { method: 'isMimeType', message: 'MIME type format' }, 'mobilephone': { method: 'isMobilePhone', message: 'mobile phone number'}, 'mobilephone-ar-AE': { method: (val) => V.isMobilePhone(val, 'ar-AE'), message: 'mobile phone number of ar-AE locale'}, 'mobilephone-ar-DZ': { method: (val) => V.isMobilePhone(val, 'ar-DZ'), message: 'mobile phone number of ar-DZ locale'}, 'mobilephone-ar-EG': { method: (val) => V.isMobilePhone(val, 'ar-EG'), message: 'mobile phone number of ar-EG locale'}, 'mobilephone-ar-IQ': { method: (val) => V.isMobilePhone(val, 'ar-IQ'), message: 'mobile phone number of ar-IQ locale'}, 'mobilephone-ar-JO': { method: (val) => V.isMobilePhone(val, 'ar-JO'), message: 'mobile phone number of ar-JO locale'},
+ 67 other calls in file
162 163 164 165 166 167 168 169 170 171
const validator = getFunctionName(location); return validator(username) .custom((paramUsername) => { if ( validatorLibrary.isEmail(paramUsername) || validatorLibrary.isMobilePhone(paramUsername) || validatorLibrary.isAlphanumeric(paramUsername, 'en-US', { ignore: '.' }) ) { return true; }
validator.escape is the most popular function in validator (548 examples)