In an ActiveRecord model, is it considered best practice/necessary to use validates_presence_of
when also using validates_length_of
?
For example:
class Company < ActiveRecord::Base
validates_presence_of :name
validates_length_of :name, :in => 5..30
end
To me, it seems redundant. Having a length between 5 and 30 means that the attribute is also present, yet I see this used everywhere. It also means users get two error messages regarding the same missing attribute, when really only one is needed.
Am I missing something, or are people being overly-zealous when validating data?