if converting to type fails, null it

This commit is contained in:
eleith 2012-10-09 03:54:45 -07:00
parent 06cb8e46ef
commit 21d7cd7746
1 changed files with 4 additions and 2 deletions

View File

@ -214,11 +214,13 @@ var is = {
var filters = {
'toInt': function(value) {
return parseInt(value, 10);
var num = parseInt(value, 10);
return _.isNaN(num) ? null : num;
},
'toFloat': function(value) {
return parseFloat(value, 10);
var num = parseFloat(value, 10);
return _.isNaN(num) ? null : num;
},
'toString': function(value) {