LearnBoost/mongoose — pull request #754 by esk525 (2012-02-29 01:47:16+00:00)
Title: SchemaNumber.prototype.cast does not handle null values

Null values are throwing a CastError for the schema type of number.

Checking the code revealed a if block wrapping most everything checking isNaN(value). If you open a node terminal and type isNaN(null), it returns false. I don't think this was the intended behavior of the check as just inside that block is a check for null.

Also, the last if check has "return new Number(ret).valueOf();" . The variable ret is not defined; so any code dropping to "return new Number(ret).valueOf();" fails.

I removed if(isNaN) check as the logic of the contained if else blocks appears to handle all cases, and I set the ret variable before using it.

Here is the code if you'd like it. I'd do more tests for you, but I am on a deadline at the moment and just need this to work.

Thanks for the awesome library.