I'm trying to validate that a number is not toll free but not sure how to set this up via the baked in validation helpers.
Here's what I have done so far:
validates :local_phone, :format => { :with => /^(\+?1)?(8(00|55|66|77|88)[2-9]\d{6})$/, :message => "cannot be a toll-free number" }
However, it validates that the number is toll free. I've tried to switch it via ! but to no avail. Before writing my own validates_with class I thought it may be best to ask around.
How to validate that a number is not toll free? Just call that number and find out :-)
He got the answer already (refer the above comment). I'm just reposting it again so that this question won't appear in "Unanswered" section.
validates :local_phone, :format => {
:with => /^(?!(+?1)?(8(00|55|66|77|88)[2-9]\d{6})).{10}$/,
:message => "cannot be a toll-free number" }
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With