Updated mongoose

This commit is contained in:
Dobie Wollert
2015-11-24 22:08:58 -08:00
parent 71a05fb732
commit 8b5827c970
618 changed files with 122299 additions and 37754 deletions

View File

@ -2,6 +2,8 @@
* Module dependencies.
*/
var utils = require('../utils');
var SchemaType = require('../schematype');
/**
@ -13,14 +15,23 @@ var SchemaType = require('../schematype');
* @api private
*/
function SchemaBoolean (path, options) {
SchemaType.call(this, path, options);
};
function SchemaBoolean(path, options) {
SchemaType.call(this, path, options, 'Boolean');
}
/**
* This schema type's name, to defend against minifiers that mangle
* function names.
*
* @api private
*/
SchemaBoolean.schemaName = 'Boolean';
/*!
* Inherits from SchemaType.
*/
SchemaBoolean.prototype.__proto__ = SchemaType.prototype;
SchemaBoolean.prototype = Object.create( SchemaType.prototype );
SchemaBoolean.prototype.constructor = SchemaBoolean;
/**
* Required validator
@ -28,7 +39,7 @@ SchemaBoolean.prototype.__proto__ = SchemaType.prototype;
* @api private
*/
SchemaBoolean.prototype.checkRequired = function (value) {
SchemaBoolean.prototype.checkRequired = function(value) {
return value === true || value === false;
};
@ -39,28 +50,16 @@ SchemaBoolean.prototype.checkRequired = function (value) {
* @api private
*/
SchemaBoolean.prototype.cast = function (value) {
SchemaBoolean.prototype.cast = function(value) {
if (null === value) return value;
if ('0' === value) return false;
if ('true' === value) return true;
if ('false' === value) return false;
return !! value;
}
return !!value;
};
/*!
* ignore
*/
function handleArray (val) {
var self = this;
return val.map(function (m) {
return self.cast(m);
});
}
SchemaBoolean.$conditionalHandlers = {
'$in': handleArray
}
SchemaBoolean.$conditionalHandlers =
utils.options(SchemaType.prototype.$conditionalHandlers, {});
/**
* Casts contents for queries.
@ -70,7 +69,7 @@ SchemaBoolean.$conditionalHandlers = {
* @api private
*/
SchemaBoolean.prototype.castForQuery = function ($conditional, val) {
SchemaBoolean.prototype.castForQuery = function($conditional, val) {
var handler;
if (2 === arguments.length) {
handler = SchemaBoolean.$conditionalHandlers[$conditional];