@@ -6,7 +6,6 @@ import {Colors, Typography} from '../../style';
66import { BaseComponent } from '../../commons' ;
77import Validators from './Validators' ;
88
9-
109const VALIDATORS = {
1110 REQUIRED : 'required' ,
1211 EMAIL : 'email' ,
@@ -90,7 +89,7 @@ export default class BaseInput extends BaseComponent {
9089 onFocus = ( ...args ) => {
9190 _ . invoke ( this . props , 'onFocus' , ...args ) ;
9291 this . setState ( { focused : true } ) ;
93- }
92+ } ;
9493
9594 onBlur = ( ...args ) => {
9695 _ . invoke ( this . props , 'onBlur' , ...args ) ;
@@ -100,11 +99,11 @@ export default class BaseInput extends BaseComponent {
10099 if ( validateOnBlur ) {
101100 this . validate ( ) ;
102101 }
103- }
102+ } ;
104103
105104 onChange = ( event ) => {
106105 _ . invoke ( this . props , 'onChange' , event ) ;
107- }
106+ } ;
108107
109108 onChangeText = ( text ) => {
110109 _ . invoke ( this . props , 'onChangeText' , text ) ;
@@ -114,7 +113,7 @@ export default class BaseInput extends BaseComponent {
114113 if ( validateOnChange ) {
115114 setImmediate ( this . validate ) ;
116115 }
117- }
116+ } ;
118117
119118 /** Actions */
120119 getTypography ( ) {
@@ -142,16 +141,17 @@ export default class BaseInput extends BaseComponent {
142141 this . input . clear ( ) ;
143142 }
144143
145- validate = ( value = _ . get ( this , 'state.value' ) , dryRun ) => { // 'input.state.value'
144+ validate = ( value = _ . get ( this , 'state.value' ) , dryRun ) => {
145+ // 'input.state.value'
146146 const { validate} = this . props ;
147147 if ( ! validate ) {
148148 return ;
149149 }
150-
150+
151+
151152 let isValid = true ;
152153 const inputValidators = _ . isArray ( validate ) ? validate : [ validate ] ;
153154 let failingValidatorIndex ;
154-
155155 // get validators
156156 for ( let index = 0 ; index < inputValidators . length ; index ++ ) {
157157 const validator = inputValidators [ index ] ;
@@ -163,7 +163,7 @@ export default class BaseInput extends BaseComponent {
163163 }
164164
165165 // validate
166- if ( ! validatorFunction ( value ) ) {
166+ if ( validatorFunction && ! validatorFunction ( value ) ) {
167167 isValid = false ;
168168 failingValidatorIndex = index ;
169169 break ;
0 commit comments