Class: UrlValidator

Inherits:
ActiveModel::EachValidator
  • Object
show all
Defined in:
lib/atreides/validators.rb

Overview

Custom validator checking for an URL

Instance Method Summary collapse

Instance Method Details

#validate_each(record, attribute, value) ⇒ Object

:nodoc:



11
12
13
14
# File 'lib/atreides/validators.rb', line 11

def validate_each(record, attribute, value) #:nodoc:
  record.errors[attribute] << (options[:message] || "is not a url") unless
    value =~ URI::regexp(%w(http https))
end