Skip to content

Add an option to throw an error if an attribute you are trying to set doesn't exist on the model you are loading#81

Open
ysoussov wants to merge 2 commits intodomasx2:masterfrom
claritymoney:master
Open

Add an option to throw an error if an attribute you are trying to set doesn't exist on the model you are loading#81
ysoussov wants to merge 2 commits intodomasx2:masterfrom
claritymoney:master

Conversation

@ysoussov
Copy link
Copy Markdown

No description provided.

Comment thread lib/loader.js
if (self.options.throwErrorOnUndefinedAttribute === true) {
throw new Error('attribute "' + key +"' not defined on model '" + Model.name + "'.");
} else {
log.warn('attribute "' + key +"' not defined on model '" + Model.name + "'.");
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should actually be log() ... log is expected to be just a plain function

Comment thread lib/loader.js
result[key] = val;
} else {
console.warn('attribute "' + key +"' not defined on model '" + Model.name + "'.");
if (self.options.throwErrorOnUndefinedAttribute === true) {
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggest: errorOnUndefinedAttribute.

Also, if (self.options.throwErrorOnUndefinedAttribute) is sufficient... anything truthy should be OK.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants