{"action":"created","issue":{"url":"https://api.github.com/repos/thoughtbot/shoulda-matchers/issues/832","labels_url":"https://api.github.com/repos/thoughtbot/shoulda-matchers/issues/832/labels{/name}","comments_url":"https://api.github.com/repos/thoughtbot/shoulda-matchers/issues/832/comments","events_url":"https://api.github.com/repos/thoughtbot/shoulda-matchers/issues/832/events","html_url":"https://github.com/thoughtbot/shoulda-matchers/issues/832","id":115348498,"number":832,"title":"validates_numericality should not recommend to remove validation","user":{"login":"ineu","id":24980,"avatar_url":"https://avatars.githubusercontent.com/u/24980?v=3","gravatar_id":"","url":"https://api.github.com/users/ineu","html_url":"https://github.com/ineu","followers_url":"https://api.github.com/users/ineu/followers","following_url":"https://api.github.com/users/ineu/following{/other_user}","gists_url":"https://api.github.com/users/ineu/gists{/gist_id}","starred_url":"https://api.github.com/users/ineu/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ineu/subscriptions","organizations_url":"https://api.github.com/users/ineu/orgs","repos_url":"https://api.github.com/users/ineu/repos","events_url":"https://api.github.com/users/ineu/events{/privacy}","received_events_url":"https://api.github.com/users/ineu/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":3,"created_at":"2015-11-05T18:52:26Z","updated_at":"2015-11-13T20:48:56Z","closed_at":null,"body":"`validates_numericality` matchers was changed with assumption that validations are there for data consistency only. But for data consistency one uses proper database column types and DB-level constraints. Validations are perfect for users.\r\n\r\nFor example, I use validates_numericality on all my columns that can be updated from forms. I want my users to see 'not a number' when they type non-number in form input. Following code recommends to remove validation which is definitely not something I want to do: https://github.com/thoughtbot/shoulda-matchers/blob/master/lib/shoulda/matchers/active_model/validate_numericality_of_matcher.rb#L522\r\n\r\nAlso, behavior described in https://github.com/thoughtbot/shoulda-matchers/issues/784#issuecomment-145155888 is not really a case. Please see following snippet:\r\n```\r\n[25] pry(main)> a = Payment.new\r\n=> #<Payment:0x00562d6b28fcf0 id: nil, account_id: nil, packet_id: nil, payment_type_id: nil, deposit: nil, amount: nil, operator_id: nil, created_at: nil>\r\n[26] pry(main)> a.amount = 'foo'\r\n=> \"foo\"\r\n[27] pry(main)> a.amount\r\n=> #<BigDecimal:562d6a0cb9d8,'0.0',9(18)>\r\n[28] pry(main)> a.valid?\r\n=> false\r\n[29] pry(main)> a.errors\r\n=> #<ActiveModel::Errors:0x00562d69e84530\r\n @base=\r\n  #<Payment:0x00562d6b28fcf0\r\n   id: nil,\r\n   account_id: nil,\r\n   packet_id: nil,\r\n   payment_type_id: nil,\r\n   deposit: nil,\r\n   amount: #<BigDecimal:562d6a0cb9d8,'0.0',9(18)>,\r\n   operator_id: nil,\r\n   created_at: nil>,\r\n @messages={:account=>[\"can't be blank\"], :packet=>[\"can't be blank\"], :payment_type=>[\"can't be blank\"], :deposit=>[\"can't be blank\"], :amount=>[\"is not a number\"]}>\r\n```\r\n\r\nAs you can see, numeric validation does add 'not a number' error, despite 'amount' is decimal column. So it matters and should neither be removed nor should raise IneffectiveTestError exception.\r\n\r\nI think there should be some kind of configuration option to disable IneffectiveTestError exception. Using validations to get nice error messages is valid and, I think, frequent use case."},"comment":{"url":"https://api.github.com/repos/thoughtbot/shoulda-matchers/issues/comments/156552534","html_url":"https://github.com/thoughtbot/shoulda-matchers/issues/832#issuecomment-156552534","issue_url":"https://api.github.com/repos/thoughtbot/shoulda-matchers/issues/832","id":156552534,"user":{"login":"axlekb","id":2972314,"avatar_url":"https://avatars.githubusercontent.com/u/2972314?v=3","gravatar_id":"","url":"https://api.github.com/users/axlekb","html_url":"https://github.com/axlekb","followers_url":"https://api.github.com/users/axlekb/followers","following_url":"https://api.github.com/users/axlekb/following{/other_user}","gists_url":"https://api.github.com/users/axlekb/gists{/gist_id}","starred_url":"https://api.github.com/users/axlekb/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/axlekb/subscriptions","organizations_url":"https://api.github.com/users/axlekb/orgs","repos_url":"https://api.github.com/users/axlekb/repos","events_url":"https://api.github.com/users/axlekb/events{/privacy}","received_events_url":"https://api.github.com/users/axlekb/received_events","type":"User","site_admin":false},"created_at":"2015-11-13T20:48:56Z","updated_at":"2015-11-13T20:48:56Z","body":"Should also point out that other case that I encountered is setting a decimal value to an integer database column, which the validation successfully enforces and messages.  Looks like that is also included in the [commit](https://github.com/thoughtbot/shoulda-matchers/commit/18b2859d2522a4866c398b9a32ebc3de4ec79389) you mentioned above."}}