Field names cannot contain a dot

pull/2/head
Louis Chatriot 12 years ago
parent 4045dd9e4a
commit cf09a75be3
  1. 6
      lib/model.js
  2. 10
      test/model.test.js

@ -20,7 +20,11 @@ var dateToJSON = function () { return { $$date: this.getTime() }; }
*/
function checkKey (k, v) {
if (k[0] === '$' && !(k === '$$date' && typeof v === 'number')) {
throw 'Keys cannot begin with the $ character';
throw 'Field names cannot begin with the $ character';
}
if (k.indexOf('.') !== -1) {
throw 'Field names cannot contain a .';
}
}

@ -148,6 +148,16 @@ describe('Model', function () {
}).should.throw();
});
it('Field names cannot contain a .', function () {
assert.isDefined(model.checkObject);
(function () {
model.checkObject({ "so.bad": true });
}).should.throw();
// Recursive behaviour testing done in the above test on $ signs
});
}); // ==== End of 'Object checking' ==== //

Loading…
Cancel
Save