waterline
Advanced tools
Comparing version 0.9.13 to 0.9.14
@@ -83,4 +83,7 @@ /** | ||
// If adapter exposes any reserved attributes, pass them to the schema | ||
var reservedAttributes = adapterInfo.adapter.reservedAttributes || {}; | ||
// Initialize internal objects from attributes | ||
this._schema.initialize(this.attributes, this.hasSchema); | ||
this._schema.initialize(this.attributes, this.hasSchema, reservedAttributes); | ||
this._cast.initialize(this._schema.schema); | ||
@@ -87,0 +90,0 @@ this._validator.initialize(this.attributes, this.types); |
@@ -48,3 +48,5 @@ /** | ||
Schema.prototype.initialize = function(attrs, hasSchema) { | ||
Schema.prototype.initialize = function(attrs, hasSchema, reservedAttributes) { | ||
var self = this; | ||
for(var key in attrs) { | ||
@@ -54,2 +56,8 @@ this.schema[key] = this.objectAttribute(attrs[key]); | ||
if(Array.isArray(reservedAttributes)) { | ||
reservedAttributes.forEach(function(key) { | ||
self.schema[key] = {}; | ||
}); | ||
} | ||
// Set hasSchema to determine if values should be cleansed or not | ||
@@ -56,0 +64,0 @@ this.hasSchema = typeof hasSchema !== 'undefined' ? hasSchema : true; |
{ | ||
"name": "waterline", | ||
"description": "An ORM for Node.js and the Sails framework", | ||
"version": "0.9.13", | ||
"version": "0.9.14", | ||
"contributors": [ | ||
@@ -6,0 +6,0 @@ { |
@@ -16,5 +16,5 @@ var Validator = require('../../../lib/waterline/core/validations'), | ||
}, | ||
employed: { | ||
type: 'boolean', | ||
required: true | ||
employed: { | ||
type: 'boolean', | ||
required: true | ||
}, | ||
@@ -29,3 +29,3 @@ age: { type: 'integer' } | ||
it('should error if no value is set for required string field', function(done) { | ||
validator.validate({ name: ' ', employed: true, age: 27 }, function(errors) { | ||
validator.validate({ name: '', employed: true, age: 27 }, function(errors) { | ||
assert(errors.ValidationError); | ||
@@ -37,3 +37,3 @@ assert(errors.ValidationError.name); | ||
}); | ||
it('should error if no value is set for required boolean field', function(done) { | ||
@@ -40,0 +40,0 @@ validator.validate({ name: 'Frederick P. Frederickson', age: 27 }, function(errors) { |
306022
127
9133