rubocop / rails-style-guide

A community-driven Ruby on Rails style guide
http://rails.rubystyle.guide
6.47k stars 1.06k forks source link

Description of Single Attribute Validations seems wrong. #325

Closed onkeld closed 2 years ago

onkeld commented 2 years ago

The passage on Single Attribute Validations currently reads as follows:

Single-attribute Validations To make validations easy to read, don’t list multiple attributes per validation.

bad

validates :email, :password, presence: true validates :email, length: { maximum: 100 }

good

validates :email, presence: true, length: { maximum: 100 } validates :password, presence: true

If I read things correctly, the rule states that we should not list multiple attributes per validation. In the examples, the good example for email validation listss presence and length (I count two attributes) where the bad example for email validations lists two separate validations - validates presence and validates length.

My understanding is that the rule actually expects to do things like in the bad example.

Shouldn't the examples be turned around here?

pirj commented 2 years ago

Attribute means "model attribute", not "validation". So, it's all good unless I am missing something.