Created
June 8, 2011 13:32
-
-
Save hugdubois/1014420 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
--- node_modules/mongoose/lib/mongoose/schema/number.js 2011-06-08 14:42:22.000000000 +0200 | |
+++ version2 2011-06-08 14:40:37.000000000 +0200 | |
@@ -84,8 +84,11 @@ | |
SchemaNumber.prototype.cast = function (value, doc) { | |
if (!isNaN(value)){ | |
if (null === value) return value; | |
- if ('' === value) return null; | |
- if ('string' === typeof value) value = Number(value); | |
+ if ('string' === typeof value) { | |
+ value = value.trim(); | |
+ if ('' === value) return null; | |
+ value = Number(value); | |
+ } | |
if (value instanceof Number || typeof value == 'number' || | |
(value.toString && value.toString() == Number(value))) | |
return new MongooseNumber(value, this.path, doc); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment