Sha256: dda185e93974dcf80b148f8e8652310c7631171c701ebea46d321b437256199c

Contents?: true

Size: 358 Bytes

Versions: 1

Compression:

Stored size: 358 Bytes

Contents

class UrlFormatValidator < ActiveModel::EachValidator
  def validate_each(record, attribute, value)
    unless URI.parse(value).kind_of?(URI::HTTP) && value =~ /\.\w{2,6}/
      record.errors[attribute] << (options[:message] || "is invalid")
    end
  rescue URI::InvalidURIError
    record.errors[attribute] << (options[:message] || "is invalid")
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
url_format-0.0.4 lib/url_format/url_format_validator.rb