I am trying to write a model for books in my rails application and I want to check the isbn attribute, but there are two possible lengths for ISBN: 10 and 13. How can I use checks to make sure that isbn is either longer than 10 OR 13?
I was thinking about using range:
validates :isbn, length: { minimum: 10, maximum: 13 }
but if it's somehow 11 or 12 numbers, this is {should_not be_valid}.
Is there any way to do this?
source share