Sha256: 6c08e998f425f488e3c96f0d2f29e2f832b4113b078e60639b42c5adfb1682e3

Contents?: true

Size: 271 Bytes

Versions: 223

Compression:

Stored size: 271 Bytes

Contents

class UrlValidator < ActiveModel::EachValidator
  def validate_each(record, attribute, value)
    url = ::Addressable::URI.parse(value)
    if url
      unless ['http', 'https'].include?(url.scheme)
        record.errors.add(attribute.to_sym)
      end
    end
  end
end

Version data entries

223 entries across 206 versions & 15 rubygems

Version Path
enju_leaf-1.1.0.rc12 lib/enju_leaf/url_validator.rb
enju_leaf-1.1.0.rc11 lib/enju_leaf/url_validator.rb
enju_leaf-1.1.0.rc10 lib/enju_leaf/url_validator.rb
enju_seed-0.1.1.pre9 lib/enju_seed/url_validator.rb
enju_seed-0.1.1.pre8 lib/enju_seed/url_validator.rb
enju_seed-0.1.1.pre7 lib/enju_seed/url_validator.rb
enju_core-0.2.0.pre2 lib/enju_core/url_validator.rb
enju_core-0.1.1.pre6 lib/enju_core/url_validator.rb
enju_core-0.1.1.pre5 lib/enju_core/url_validator.rb
enju_core-0.2.0.pre1 lib/enju_core/url_validator.rb
enju_core-0.1.1.pre4 lib/enju_core/url_validator.rb
enju_news-0.1.0.pre3 spec/dummy/lib/url_validator.rb
enju_core-0.1.1.pre3 lib/enju_core/url_validator.rb
enju_core-0.1.1.pre2 lib/enju_core/url_validator.rb
enju_bookmark-0.1.2.pre3 spec/dummy/lib/enju_leaf/url_validator.rb
enju_bookmark-0.1.2.pre2 spec/dummy/lib/enju_leaf/url_validator.rb
enju_bookmark-0.1.2.pre spec/dummy/lib/enju_leaf/url_validator.rb
enju_core-0.1.1.pre lib/enju_core/url_validator.rb
enju_news-0.1.0.pre2 spec/dummy/lib/url_validator.rb
enju_bookmark-0.1.1 spec/dummy/lib/enju_leaf/url_validator.rb