File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1+ /**
2+ *
3+ * example
4+ *
5+ * @description
6+ * @author Fantasy <fantasyshao@icloud.com>
7+ * @create 2014-09-08
8+ * @update 2014-09-08
9+ */
10+
11+ var validator = require ( '../lib' ) ;
12+
13+ // isEmail
14+ console . log ( validator . isEmail ( 'test@gmail.com' ) ) ;
15+
16+ // isAllChinese
17+ console . log ( validator . isAllChinese ( '测试' ) ) ;
18+
19+ // isAllEnglish
20+ console . log ( validator . isAllEnglish ( 'test' ) ) ;
21+
22+ // isAllDigit
23+ console . log ( validator . isAllDigit ( '12345' ) ) ;
Original file line number Diff line number Diff line change 22 *
33 * index
44 *
5- * @description
5+ * @description entrance
66 * @author Fantasy <fantasyshao@icloud.com>
77 * @create 2014-09-08
88 * @update 2014-09-08
Original file line number Diff line number Diff line change 88 * @update 2014-09-08
99 */
1010
11+ module . exports = {
12+
13+ isEmail : function ( str ) {
14+ return / ^ [ a - z 0 - 9 ! # $ % & ' * + \/ = ? ^ _ ` { | } ~ . - ] + @ [ a - z 0 - 9 - ] + ( \. [ a - z 0 - 9 - ] + ) * $ / i. test ( str ) ;
15+ } ,
16+
17+ isAllChinese : function ( str ) {
18+ return ! / [ ^ \u4e00 - \u9fa5 ] / . test ( str ) ;
19+ } ,
20+
21+ isAllEnglish : function ( str ) {
22+ return / ^ [ a - z A - Z ] + $ / . test ( str ) ;
23+ } ,
24+
25+ isAllDigit : function ( str ) {
26+ return / ^ [ 0 - 9 ] + $ / . test ( str ) ;
27+ } ,
28+
29+ isChineseTel : function ( str ) {
30+ return / ^ 1 [ 3 4 5 7 8 ] \d { 9 } $ / . test ( str ) ;
31+ }
32+
33+ } ;
Original file line number Diff line number Diff line change 11{
22 "name" : " is-valid" ,
3- "version" : " 0.0.1 " ,
3+ "version" : " 0.0.2 " ,
44 "description" : " String validator for more" ,
55 "main" : " index.js" ,
66 "scripts" : {
2121 "bugs" : {
2222 "url" : " https://github.com/SFantasy/node-validator/issues"
2323 },
24- "homepage" : " https://github.com/SFantasy/node-validator"
24+ "homepage" : " https://github.com/SFantasy/node-validator" ,
25+ "dependencies" : {}
2526}
You can’t perform that action at this time.
0 commit comments