Method: ActiveModel::Validations::UrlValidator#initialize
- Defined in:
- lib/active_validators/active_model/validations/url_validator.rb
#initialize(options) ⇒ UrlValidator
Public: Creates a new instance, overrides :protocols if either :with or :in are defined, to allow for shortcut setters.
Examples:
validates :url, :url => { :protocols => %w{http https ftp} }
# => accepts http, https and ftp URLs
validates :url, :url => 'https'
# => accepts only https URLs (shortcut form of above)
validates :url, :url => true
# => by default allows only http and https
Raises an ArgumentError if the array with the allowed protocols is empty.
Returns a new instance.
38 39 40 41 |
# File 'lib/active_validators/active_model/validations/url_validator.rb', line 38 def initialize() [:protocols] ||= .delete(:protocol) || .delete(:with) || .delete(:in) super end |