@@ -16,10 +16,8 @@ module.exports = function() {
16
16
this . messages . types . instance ,
17
17
this . field , Type . name || 'function (anonymous)' ) ;
18
18
}
19
- // null type
20
19
} else if ( id === 'null' ) {
21
20
invalid = this . value !== null ;
22
- // regexp as RegExp or valid string expression
23
21
} else if ( id === 'regexp' ) {
24
22
if ( ! ( this . value instanceof RegExp ) ) {
25
23
try {
@@ -28,28 +26,19 @@ module.exports = function() {
28
26
invalid = true ;
29
27
}
30
28
}
31
- // string type
32
29
} else if ( id === 'string' ) {
33
30
invalid = typeof this . value !== 'string' && this . validates ( ) ;
34
- // object type
35
31
} else if ( id === 'object' ) {
36
32
invalid = ( typeof ( this . value ) !== 'object'
37
33
|| Array . isArray ( this . value ) ) ;
38
- // array type
39
34
} else if ( id === 'array' ) {
40
35
invalid = ! Array . isArray ( this . value ) ;
41
- // float type
42
36
} else if ( id === 'float' ) {
43
37
invalid = typeof ( this . value ) !== 'number'
44
38
|| Number ( this . value ) === parseInt ( this . value ) ;
45
- // integer type
46
39
} else if ( id === 'integer' ) {
47
40
invalid = typeof ( this . value ) !== 'number'
48
41
|| Number ( this . value ) !== parseInt ( this . value ) ;
49
- // TODO: rename method -> function so that it can share the
50
- // TODO: conditional below
51
- } else if ( id === 'method' ) {
52
- invalid = typeof ( this . value ) !== 'function' ;
53
42
// straight typeof test
54
43
} else {
55
44
invalid = typeof ( this . value ) !== id ;
@@ -69,7 +58,7 @@ module.exports = function() {
69
58
* @param cb Callback function.
70
59
*/
71
60
function types ( cb ) {
72
- var types = this . rule . type . slice ( 0 )
61
+ var list = this . rule . type . slice ( 0 )
73
62
, i
74
63
, type
75
64
, length = this . errors . length
@@ -78,8 +67,8 @@ module.exports = function() {
78
67
if ( this . validates ( ) ) {
79
68
this . required ( ) ;
80
69
81
- for ( i = 0 ; i < types . length ; i ++ ) {
82
- type = types [ i ] ;
70
+ for ( i = 0 ; i < list . length ; i ++ ) {
71
+ type = list [ i ] ;
83
72
delete this . rule . Type ;
84
73
if ( typeof type === 'function' ) {
85
74
this . rule . Type = type ;
0 commit comments