Skip to content

Commit

Permalink
Add missing absence validations to Rails/Validation (#6941)
Browse files Browse the repository at this point in the history
  • Loading branch information
jmanian authored and bbatsov committed Apr 17, 2019
1 parent 2814669 commit 0aebdab
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 0 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Expand Up @@ -12,6 +12,7 @@

* Do not annotate message with cop name in JSON output. ([@elebow][])
* [#6914](https://github.com/rubocop-hq/rubocop/issues/6914): [Fix #6914] Fix an error for `Rails/RedundantAllowNil` when with interpolations. ([@Blue-Pix][])
* [#6941](https://github.com/rubocop-hq/rubocop/issues/6941): Add missing absence validations to `Rails/Validation`. ([@jmanian][])

### Changes

Expand Down Expand Up @@ -3946,3 +3947,4 @@
[@thomthom]: https://github.com/thomthom
[@Blue-Pix]: https://github.com/Blue-Pix
[@Mange]: https://github.com/Mange
[@jmanian]: https://github.com/jmanian
3 changes: 3 additions & 0 deletions lib/rubocop/cop/rails/validation.rb
Expand Up @@ -15,6 +15,7 @@ module Rails
# validates_length_of :foo
# validates_numericality_of :foo
# validates_presence_of :foo
# validates_absence_of :foo
# validates_size_of :foo
# validates_uniqueness_of :foo
#
Expand All @@ -27,6 +28,7 @@ module Rails
# validates :foo, length: true
# validates :foo, numericality: true
# validates :foo, presence: true
# validates :foo, absence: true
# validates :foo, size: true
# validates :foo, uniqueness: true
#
Expand All @@ -43,6 +45,7 @@ class Validation < Cop
length
numericality
presence
absence
size
uniqueness
].freeze
Expand Down
2 changes: 2 additions & 0 deletions manual/cops_rails.md
Expand Up @@ -2350,6 +2350,7 @@ validates_inclusion_of :foo
validates_length_of :foo
validates_numericality_of :foo
validates_presence_of :foo
validates_absence_of :foo
validates_size_of :foo
validates_uniqueness_of :foo

Expand All @@ -2362,6 +2363,7 @@ validates :foo, inclusion: true
validates :foo, length: true
validates :foo, numericality: true
validates :foo, presence: true
validates :foo, absence: true
validates :foo, size: true
validates :foo, uniqueness: true
```
Expand Down

0 comments on commit 0aebdab

Please sign in to comment.