I want to use the same validation type (but with different options based on a condition) for the same field multiple times, like in the example below:
validates :something, :length => { :minimum => 1, :if => :some_condition1 }
validates :something, :length => { :minimum => 2, :maximum => 20, :if => :some_condition2 }
validates :something, :length => { :minimum => 10, :unless => :some_condition3 }
But such way will not work correctly, since only the last validation would apply.
Is there any other way to do such thing?
The correct syntax is:
Take the conditions outside the length’s options.
Also you can take a look at Conditional Validations for more information