Skip to content

Commit

Permalink
Factored out if statement predicate for readability
Browse files Browse the repository at this point in the history
  • Loading branch information
JeroenDeDauw committed Jul 29, 2016
1 parent a8f659d commit f6c2b02
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions app/js/lib/form_validation.js
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,7 @@ var jQuery = require( 'jquery' ),
status: 'OK'
};
}

if ( formValues.debitType === 'sepa' ) {
data = {
iban: formValues.iban
Expand All @@ -100,11 +101,15 @@ var jQuery = require( 'jquery' ),
};
validationUrl = this.validationUrlForNonSepa;
}
// avoid sending incomplete data to the server
if ( _.find( data, isEmptyString ) !== undefined ) {

if ( this.dataIsIncomplete( data ) ) {
return { status: 'INCOMPLETE' };
}

return this.sendFunction( validationUrl, data, null, 'json' );
},
dataIsIncomplete: function ( data ) {
return _.find( data, isEmptyString ) !== undefined;
}
},

Expand Down

0 comments on commit f6c2b02

Please sign in to comment.