File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -36,6 +36,8 @@ validator.isEmail('abc@gmail.com'); // => true
3636- isAllDigit(str): check if it is a string only contains digits
3737- isChineseTel(str): check if it is a Chinese cell-phone number
3838- isChineseIdCard(str): check if it is a 18-digit Chinese ID card number
39+ - isVisaCard(str): check if it is a Visa card
40+ - isMasterCard(str): check if it is a Master card
3941
4042## Test
4143
Original file line number Diff line number Diff line change @@ -95,6 +95,24 @@ module.exports = {
9595
9696 return temp [ 17 ] === validCodeArr [ sum % 11 ] ;
9797 }
98+ } ,
99+
100+ /**
101+ * check if it is a Visa card
102+ * @param str
103+ * @returns {boolean }
104+ */
105+ isVisaCard : function ( str ) {
106+ return / ^ 4 [ 0 - 9 ] { 12 } (?: [ 0 - 9 ] { 3 } ) ? $ / . test ( str ) ;
107+ } ,
108+
109+ /**
110+ * check if it is a Master card
111+ * @param str
112+ * @returns {boolean }
113+ */
114+ isMasterCard : function ( str ) {
115+ return / ^ 5 [ 1 - 5 ] [ 0 - 9 ] { 14 } $ / . test ( str ) ;
98116 }
99117
100118} ;
Original file line number Diff line number Diff line change 11{
22 "name" : " is-valid" ,
3- "version" : " 0.0.3 " ,
3+ "version" : " 0.1.0 " ,
44 "description" : " String validator for more" ,
55 "main" : " index.js" ,
66 "scripts" : {
You can’t perform that action at this time.
0 commit comments