@@ -6,7 +6,6 @@ import {Colors, Typography} from '../../style';
6
6
import { BaseComponent } from '../../commons' ;
7
7
import Validators from './Validators' ;
8
8
9
-
10
9
const VALIDATORS = {
11
10
REQUIRED : 'required' ,
12
11
EMAIL : 'email' ,
@@ -90,7 +89,7 @@ export default class BaseInput extends BaseComponent {
90
89
onFocus = ( ...args ) => {
91
90
_ . invoke ( this . props , 'onFocus' , ...args ) ;
92
91
this . setState ( { focused : true } ) ;
93
- }
92
+ } ;
94
93
95
94
onBlur = ( ...args ) => {
96
95
_ . invoke ( this . props , 'onBlur' , ...args ) ;
@@ -100,11 +99,11 @@ export default class BaseInput extends BaseComponent {
100
99
if ( validateOnBlur ) {
101
100
this . validate ( ) ;
102
101
}
103
- }
102
+ } ;
104
103
105
104
onChange = ( event ) => {
106
105
_ . invoke ( this . props , 'onChange' , event ) ;
107
- }
106
+ } ;
108
107
109
108
onChangeText = ( text ) => {
110
109
_ . invoke ( this . props , 'onChangeText' , text ) ;
@@ -114,7 +113,7 @@ export default class BaseInput extends BaseComponent {
114
113
if ( validateOnChange ) {
115
114
setImmediate ( this . validate ) ;
116
115
}
117
- }
116
+ } ;
118
117
119
118
/** Actions */
120
119
getTypography ( ) {
@@ -142,16 +141,17 @@ export default class BaseInput extends BaseComponent {
142
141
this . input . clear ( ) ;
143
142
}
144
143
145
- validate = ( value = _ . get ( this , 'state.value' ) , dryRun ) => { // 'input.state.value'
144
+ validate = ( value = _ . get ( this , 'state.value' ) , dryRun ) => {
145
+ // 'input.state.value'
146
146
const { validate} = this . props ;
147
147
if ( ! validate ) {
148
148
return ;
149
149
}
150
-
150
+
151
+
151
152
let isValid = true ;
152
153
const inputValidators = _ . isArray ( validate ) ? validate : [ validate ] ;
153
154
let failingValidatorIndex ;
154
-
155
155
// get validators
156
156
for ( let index = 0 ; index < inputValidators . length ; index ++ ) {
157
157
const validator = inputValidators [ index ] ;
@@ -163,7 +163,7 @@ export default class BaseInput extends BaseComponent {
163
163
}
164
164
165
165
// validate
166
- if ( ! validatorFunction ( value ) ) {
166
+ if ( validatorFunction && ! validatorFunction ( value ) ) {
167
167
isValid = false ;
168
168
failingValidatorIndex = index ;
169
169
break ;
0 commit comments