Sha256: d03bfb72b3b7fb6243e87dc5777378f44e9d05b13b1d02b4d5f05574a6bce6d9
Contents?: true
Size: 354 Bytes
Versions: 54
Compression:
Stored size: 354 Bytes
Contents
class UrlValidator < ActiveModel::EachValidator def validate_each(record, attribute, value) if value =~ /\Ahttps?:\/\/[^\n]+\z/i url = ::Addressable::URI.parse(value) unless ['http', 'https'].include?(url.scheme) record.errors.add(attribute.to_sym) end else record.errors.add(attribute.to_sym) end end end
Version data entries
54 entries across 52 versions & 2 rubygems