notification-methods/models/notification_method.rb
def valid_target
        if method == 'text'
            errors.add(:target, "That doesn't look like a phone number.") unless target.length == 10
        end

        if method == 'email'
            errors.add(:target, "That doesn't look like an email address.") unless target.include? '@'
        end
    end
# A custom validation here makes sure that our phone numbers and emails
# look something like they're supposed to.
A custom validation here makes sure that our phone numbers and emails
look something like they're supposed to.
A custom validation here makes sure that our phone numbers and emails look something like they ' re supposed to .
def valid_target
        if method == 'text'
            errors.add(:target, "That doesn't look like a phone number.") unless target.length == 10
        end
        if method == 'email'
            errors.add(:target, "That doesn't look like an email address.") unless target.include? '@'
        end
    end
def valid_target if method == 'text' errors . add ( :target , "That doesn't look like a phone number." ) unless target . length == 10 end if method == 'email' errors . add ( :target , "That doesn't look like an email address." ) unless target . include? '@' end end
A custom validation here makes sure that our phone numbers and emails
look something like they're supposed to.
A custom validation here makes sure that our phone numbers and emails look something like they ' re supposed to .