Sha256: 999db8bc22a042970a0681018faa434269168469a843df3e67d0c7d925457bf6

Contents?: true

Size: 314 Bytes

Versions: 62

Compression:

Stored size: 314 Bytes

Contents

class UrlValidator < ActiveModel::EachValidator
  def self.valid_url?(value)
    !!URI.regexp(%w(http https)).match(value.to_s)
  end

  def validate_each(record, attribute, value)
    unless self.class.valid_url?(value)
      record.errors[attribute] << (options[:message] || "must be a valid")
    end
  end
end

Version data entries

62 entries across 62 versions & 1 rubygems

Version Path
workarea-core-3.5.15 lib/workarea/validators/url_validator.rb
workarea-core-3.4.36 lib/workarea/validators/url_validator.rb
workarea-core-3.5.14 lib/workarea/validators/url_validator.rb
workarea-core-3.4.35 lib/workarea/validators/url_validator.rb
workarea-core-3.5.13 lib/workarea/validators/url_validator.rb
workarea-core-3.4.34 lib/workarea/validators/url_validator.rb
workarea-core-3.5.12 lib/workarea/validators/url_validator.rb
workarea-core-3.4.33 lib/workarea/validators/url_validator.rb
workarea-core-3.5.11 lib/workarea/validators/url_validator.rb
workarea-core-3.5.10 lib/workarea/validators/url_validator.rb
workarea-core-3.4.32 lib/workarea/validators/url_validator.rb
workarea-core-3.5.9 lib/workarea/validators/url_validator.rb
workarea-core-3.4.31 lib/workarea/validators/url_validator.rb
workarea-core-3.5.8 lib/workarea/validators/url_validator.rb
workarea-core-3.4.30 lib/workarea/validators/url_validator.rb
workarea-core-3.5.7 lib/workarea/validators/url_validator.rb
workarea-core-3.4.29 lib/workarea/validators/url_validator.rb
workarea-core-3.5.6 lib/workarea/validators/url_validator.rb
workarea-core-3.4.28 lib/workarea/validators/url_validator.rb
workarea-core-3.5.5 lib/workarea/validators/url_validator.rb