Displaying 1 result from an estimated 1 matches for "drys".
Did you mean:
days
2006 Apr 27
0
DRY validation
...a.validates_format :with => /\A[A-Z]+\z/
a.validates_uniqueness
end
attribute :phone_code, :integer, :allow_nil => true do |a|
a.validates_numericality :greater_than_or_equal_to =>
1, :less_than_or_equal_to => 9999
end
end
The advantage of this it DRYs up the validation rules since you
don''t have to specify the name of the attribute over and over.
Plus it automatically sets validates_presence_of for the attribute
unless you set allow_nil as true -- as shown in the phone_code
attribute above.
The plugin can be downloaded from here:
h...