Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

ysoussov
Copy link

No description provided.

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
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

@@ -221,7 +221,11 @@ Loader.prototype.prepFixtureData = function(data, Model) {
if (Model.attributes.hasOwnProperty(key)) {
result[key] = val;
} else {
console.warn('attribute "' + key +"' not defined on model '" + Model.name + "'.");
if (self.options.throwErrorOnUndefinedAttribute === true) {
Copy link
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