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.27 lib/workarea/validators/url_validator.rb
workarea-core-3.5.26 lib/workarea/validators/url_validator.rb
workarea-core-3.4.45 lib/workarea/validators/url_validator.rb
workarea-core-3.5.25 lib/workarea/validators/url_validator.rb
workarea-core-3.5.23 lib/workarea/validators/url_validator.rb
workarea-core-3.4.44 lib/workarea/validators/url_validator.rb
workarea-core-3.5.22 lib/workarea/validators/url_validator.rb
workarea-core-3.4.43 lib/workarea/validators/url_validator.rb
workarea-core-3.5.21 lib/workarea/validators/url_validator.rb
workarea-core-3.4.42 lib/workarea/validators/url_validator.rb
workarea-core-3.5.20 lib/workarea/validators/url_validator.rb
workarea-core-3.4.41 lib/workarea/validators/url_validator.rb
workarea-core-3.5.19 lib/workarea/validators/url_validator.rb
workarea-core-3.4.40 lib/workarea/validators/url_validator.rb
workarea-core-3.5.18 lib/workarea/validators/url_validator.rb
workarea-core-3.4.39 lib/workarea/validators/url_validator.rb
workarea-core-3.5.17 lib/workarea/validators/url_validator.rb
workarea-core-3.4.38 lib/workarea/validators/url_validator.rb
workarea-core-3.5.16 lib/workarea/validators/url_validator.rb
workarea-core-3.4.37 lib/workarea/validators/url_validator.rb