Skip to content

Commit

Permalink
Buffers shouldn't have default vals
Browse files Browse the repository at this point in the history
  • Loading branch information
aheckmann committed Sep 1, 2011
1 parent 43ae07b commit 9ab40a6
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 16 deletions.
14 changes: 0 additions & 14 deletions lib/schema/buffer.js
Expand Up @@ -19,20 +19,6 @@ var SchemaType = require('../schematype')

function SchemaBuffer (key, options) {
SchemaType.call(this, key, options);

var self = this
, defaultBuf
, fn;

if (this.defaultValue) {
defaultBuf = this.defaultValue;
fn = 'function' == typeof defaultBuf;
}

this.default(function(){
var buf = fn ? defaultBuf() : defaultBuf || null;
return new MongooseBuffer(buf, [self.path, this]);
});
};

/**
Expand Down
4 changes: 2 additions & 2 deletions test/types.buffer.test.js
Expand Up @@ -13,7 +13,7 @@ var start = require('./common')
// can't index Buffer fields yet

function valid (v) {
return v.length > 10;
return !v || v.length > 10;
}

var subBuf = new Schema({
Expand Down Expand Up @@ -75,7 +75,7 @@ module.exports = {
t.sub.push({ name: 'Friday Friday' });
t.save(function (err) {
err.message.should.eql('Validation failed');
err.errors.buf.type.should.equal('valid failed');
err.errors.buf.type.should.equal('required');
t.sub[0].buf = new Buffer("well well");
t.save(function (err) {
err.message.should.eql('Validation failed');
Expand Down

0 comments on commit 9ab40a6

Please sign in to comment.