Every line of 'yup number validation' code snippets is scanned for vulnerabilities by our powerful machine learning engine that combs millions of open source libraries, ensuring your JavaScript code is secure.
8 function validateNumber(num) { 9 num = (num + '').replace(/\s+|-/g, ''); 10 11 if (!/^\d+$/.test(num)) { 12 return false; 13 } 14 15 var card = cardFromNumber(num); 16 17 if (card) { 18 var cardNumbers = A(card.length); 19 20 return ( cardNumbers.includes(num.length)) && (card.luhn === false || luhnCheck(num)); 21 } 22 23 return false; 24 }
45 function verify(number) { 46 if (!_.isNumber(number)) { 47 throw new Error('Wrong log level specified!'); 48 } 49 return number; 50 }
149 validateNumber: function validateNumber(name) { 150 var opts = arguments[1] === undefined ? {} : arguments[1]; 151 152 if (util.type(this[name]) === "number") { 153 if (opts.nonnegative && this[name] < 0) { 154 this.addError(name, "must not be negative"); 155 } 156 157 if (opts.maximum && this[name] > opts.maximum) { 158 this.addError(name, "may not be greater than " + opts.maximum); 159 } 160 161 if (opts.minimum && this[name] < opts.minimum) { 162 this.addError(name, "may not be less than " + opts.minimum); 163 } 164 } else if (!isBlank(this["" + name + "BeforeCoercion"])) { 165 this.addError(name, "is not a number"); 166 } 167 },