The example list at the following link: Validation shows the following example of using the validate function:
validate: function (attrs) { for (var key in attrs) { var value = attrs[key]; if (key === "title") { if (value.length <= 0) { return "Error: No title!"; } } } if (key === "author") { if (value.length <= 0) { return "Error: No author!"; } } },My question why iterate through the attrs array when you can just access the properties of attrs using dot syntax, i.e. "attrs.key". For example, I could access the properties of the passed in attrs using the following dot syntax if the "key" property was part of the passed in attrs:
validate: function (attrs) { if (attrs.key === "title"){ return "Error: No title!"; } },Is there some reason I should be iterating through the array like the example in the documents show?