Reputation: 385
I want to check a string for exactly 8 or 10 characters.
Is there a possibility with validates_length_of?
Upvotes: 1
Views: 913
Reputation: 11628
Just do this
class Foo
validate :check_length
def check_length
unless column.size == 8 or column.size == 10
errors.add(:column, "length must be 8 or 10")
end
end
end
You get the idea.
Upvotes: 3