Skip to content
This repository has been archived by the owner on Jun 9, 2018. It is now read-only.

Commit

Permalink
return null if instantiated without data, #1
Browse files Browse the repository at this point in the history
  • Loading branch information
MartijnR committed Dec 31, 2013
1 parent c1e1bfd commit 95a7a56
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion src/FormModelJSON.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ define( [ 'jquery', 'jquery.xpath' ], function( $ ) {

if ( typeof data !== 'object' ) {
recordError( "error: no JSON object provided during instantiation" );
return null;
}
//main form:
for ( i = 0; i < data.form.fields.length; i++ ) {
Expand Down Expand Up @@ -236,7 +237,9 @@ define( [ 'jquery', 'jquery.xpath' ], function( $ ) {
}

function recordError( errorMsg ) {
if ( typeof data.errors == 'undefined' ) data.errors = [];
if ( typeof data.errors == 'undefined' ) {
data.errors = [];
}
data.errors.push( errorMsg );
console.error( errorMsg );
}
Expand Down

0 comments on commit 95a7a56

Please sign in to comment.