rails-style-guide icon indicating copy to clipboard operation
rails-style-guide copied to clipboard

Description of Single Attribute Validations seems wrong.

Open onkeld opened this issue 3 years ago • 0 comments

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?

onkeld avatar Aug 10 '22 08:08 onkeld

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

pirj avatar Aug 11 '22 14:08 pirj