diff --git a/lib/dao.js b/lib/dao.js index 9527d17d..55846e7e 100644 --- a/lib/dao.js +++ b/lib/dao.js @@ -768,17 +768,28 @@ DataAccessObject._normalize = function (filter) { }; function DateType(arg) { - return new Date(arg); + var d = new Date(arg); + if (isNaN(d.getTime())) { + throw new Error('Invalid date: ' + arg); + } + return d; } -function BooleanType(val) { - if (val === 'true') { - return true; - } else if (val === 'false') { - return false; - } else { - return Boolean(val); +function BooleanType(arg) { + if (typeof arg === 'string') { + switch (arg) { + case 'true': + case '1': + return true; + case 'false': + case '0': + return false; + } } + if (arg == null) { + return null; + } + return Boolean(arg); } function NumberType(val) {