mirror of
https://github.com/atlanticbiomedical/biomedjs.git
synced 2025-07-02 00:47:26 -04:00
Updated mongoose
This commit is contained in:
45
node_modules/mongoose/lib/schema/boolean.js
generated
vendored
45
node_modules/mongoose/lib/schema/boolean.js
generated
vendored
@ -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];
|
||||
|
Reference in New Issue
Block a user