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
Open
Conversation
added 2 commits
October 23, 2017 15:13
…del you are trying to load
matmar10
requested changes
Apr 22, 2019
| 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 + "'."); |
Collaborator
There was a problem hiding this comment.
This should actually be log() ... log is expected to be just a plain function
| result[key] = val; | ||
| } else { | ||
| console.warn('attribute "' + key +"' not defined on model '" + Model.name + "'."); | ||
| if (self.options.throwErrorOnUndefinedAttribute === true) { |
Collaborator
There was a problem hiding this comment.
Suggest: errorOnUndefinedAttribute.
Also, if (self.options.throwErrorOnUndefinedAttribute) is sufficient... anything truthy should be OK.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
No description provided.