{"action":"opened","issue":{"url":"https://api.github.com/repos/strongloop/strong-remoting/issues/322","repository_url":"https://api.github.com/repos/strongloop/strong-remoting","labels_url":"https://api.github.com/repos/strongloop/strong-remoting/issues/322/labels{/name}","comments_url":"https://api.github.com/repos/strongloop/strong-remoting/issues/322/comments","events_url":"https://api.github.com/repos/strongloop/strong-remoting/issues/322/events","html_url":"https://github.com/strongloop/strong-remoting/issues/322","id":165706298,"number":322,"title":"[bug] can not identify the undefiend/null value of the boolean type argument.","user":{"login":"snowyu","id":327887,"avatar_url":"https://avatars.githubusercontent.com/u/327887?v=3","gravatar_id":"","url":"https://api.github.com/users/snowyu","html_url":"https://github.com/snowyu","followers_url":"https://api.github.com/users/snowyu/followers","following_url":"https://api.github.com/users/snowyu/following{/other_user}","gists_url":"https://api.github.com/users/snowyu/gists{/gist_id}","starred_url":"https://api.github.com/users/snowyu/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/snowyu/subscriptions","organizations_url":"https://api.github.com/users/snowyu/orgs","repos_url":"https://api.github.com/users/snowyu/repos","events_url":"https://api.github.com/users/snowyu/events{/privacy}","received_events_url":"https://api.github.com/users/snowyu/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":0,"created_at":"2016-07-15T03:52:24Z","updated_at":"2016-07-15T03:52:24Z","closed_at":null,"body":"It always be converted false. It should not narrow it.\r\n\r\nlib/dynamic.js:\r\n\r\n```js\r\nDynamic.define('boolean', function convertBoolean(val) {\r\n  switch (typeof val) {\r\n    case 'string':\r\n      switch (val) {\r\n        case 'false':\r\n        case 'undefined':\r\n        case 'null':\r\n        case '0':\r\n        case '':\r\n          return false;\r\n        default:\r\n          return true;\r\n      }\r\n      break;\r\n    case 'number':\r\n      return val !== 0;\r\n    default:\r\n      return Boolean(val);\r\n  }\r\n});\r\n```\r\n\r\nCorrection:\r\n\r\n```js\r\nDynamic.define('boolean', function convertBoolean(val) {\r\n  switch (typeof val) {\r\n    case 'string':\r\n      switch (val.trim().toLowerCase()) {\r\n        case 'false':\r\n        case '0':\r\n        case '':\r\n          return false;\r\n        case 'undefined': return undefined;\r\n        case 'null': return null; //others still convert the null to false!! why??\r\n        default:\r\n          return true;\r\n      }\r\n      break;\r\n    case 'number':\r\n      return val !== 0;\r\n    default:\r\n      if (val !== null and val !== void 0)\r\n        val = Boolean(val);\r\n     return val;\r\n  }\r\n});\r\n```\r\n\r\n\r\n"}}
{"actor":{"display_login":"snowyu"}}