Class: UrlValidator

Inherits:
BaseValidator show all
Defined in:
lib/lite/validators/url_validator.rb

Constant Summary collapse

SCHEMES =
%w[
  http https
].freeze

Instance Method Summary collapse

Instance Method Details

#validate_each(record, attribute, value) ⇒ Object



11
12
13
14
15
16
# File 'lib/lite/validators/url_validator.rb', line 11

def validate_each(record, attribute, value)
  assign_attr_readers(record, attribute, URI.parse(value.to_s))
  valid_attr?
rescue URI::InvalidURIError
  record.errors.add(attribute, *error_message)
end