{"action":"created","issue":{"url":"https://api.github.com/repos/bgrins/TinyColor/issues/115","labels_url":"https://api.github.com/repos/bgrins/TinyColor/issues/115/labels{/name}","comments_url":"https://api.github.com/repos/bgrins/TinyColor/issues/115/comments","events_url":"https://api.github.com/repos/bgrins/TinyColor/issues/115/events","html_url":"https://github.com/bgrins/TinyColor/issues/115","id":120926316,"number":115,"title":"Check if rgb property isValid()","user":{"login":"Horray","id":12147037,"avatar_url":"https://avatars.githubusercontent.com/u/12147037?v=3","gravatar_id":"","url":"https://api.github.com/users/Horray","html_url":"https://github.com/Horray","followers_url":"https://api.github.com/users/Horray/followers","following_url":"https://api.github.com/users/Horray/following{/other_user}","gists_url":"https://api.github.com/users/Horray/gists{/gist_id}","starred_url":"https://api.github.com/users/Horray/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Horray/subscriptions","organizations_url":"https://api.github.com/users/Horray/orgs","repos_url":"https://api.github.com/users/Horray/repos","events_url":"https://api.github.com/users/Horray/events{/privacy}","received_events_url":"https://api.github.com/users/Horray/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":1,"created_at":"2015-12-08T04:12:25Z","updated_at":"2015-12-13T22:34:23Z","closed_at":null,"body":" I created an object with rgb property's and invalid values:\r\n\r\n    value = {r: 'abc', g: 'something', b: 'hello'};\r\n\r\nI then created an if-statement checking whether it's a valid color:\r\n\r\nif (tinycolor(value).isValid()) {\r\n    console.log(\"Good :)\");\r\n} else {\r\n    console.log(\"Wrong!!!\");\r\n}\r\n\r\nNo matter what values I give, I always get 'Good :)' logged. I then tried using a string instead;\r\n\r\nvalue = 'rgb (abc, something, hello)';\r\nAnd that gives me the correct output. If it's an invalid color, I get 'Wrong!!!', and if it's a valid color, I get 'Good :)'.\r\n\r\nI then checked the code, and saw that `isValid()` checks for valid propertys, not values. When using rgb object, how can I check if the color is valid?\r\n\r\n(I want values from 0 - 255, not percentage or decimal.)"},"comment":{"url":"https://api.github.com/repos/bgrins/TinyColor/issues/comments/164306718","html_url":"https://github.com/bgrins/TinyColor/issues/115#issuecomment-164306718","issue_url":"https://api.github.com/repos/bgrins/TinyColor/issues/115","id":164306718,"user":{"login":"bgrins","id":95570,"avatar_url":"https://avatars.githubusercontent.com/u/95570?v=3","gravatar_id":"","url":"https://api.github.com/users/bgrins","html_url":"https://github.com/bgrins","followers_url":"https://api.github.com/users/bgrins/followers","following_url":"https://api.github.com/users/bgrins/following{/other_user}","gists_url":"https://api.github.com/users/bgrins/gists{/gist_id}","starred_url":"https://api.github.com/users/bgrins/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/bgrins/subscriptions","organizations_url":"https://api.github.com/users/bgrins/orgs","repos_url":"https://api.github.com/users/bgrins/repos","events_url":"https://api.github.com/users/bgrins/events{/privacy}","received_events_url":"https://api.github.com/users/bgrins/received_events","type":"User","site_admin":false},"created_at":"2015-12-13T22:34:23Z","updated_at":"2015-12-13T22:34:23Z","body":"Looks like there's a bug with object input where we should be validating that it matches the expected input format and not just returning ok = true if it has the properties.\r\n\r\nRegarding wanting values to be within 0 - 255 or percentage / decimal, right now we make no attempt to call those invalid to more closely match CSS behavior (for instance, `rgb(-100, 0, 1000)` is blue).  So if you are specifically wanting numeric input that fits within that range you might need to do an additional check on top of isValid() to validate that."}}