Sha256: c1b7cd00ee277c5f92f0a53dcb541c0a9ad300c22c03bd7568594ea2bbe58c98

Contents?: true

Size: 287 Bytes

Versions: 72

Compression:

Stored size: 287 Bytes

Contents

class UrlValidator < ActiveModel::EachValidator
  def validate_each(record, attribute, value)
    valid = begin
      URI.parse(value).kind_of?(URI::HTTP)
    rescue URI::InvalidURIError
      false
    end

    unless valid
      record.errors.add attribute, :invalid
    end
  end
end

Version data entries

72 entries across 72 versions & 1 rubygems

Version Path
udongo-7.9.0 app/validators/url_validator.rb
udongo-7.8.1 app/validators/url_validator.rb
udongo-7.8.0 app/validators/url_validator.rb
udongo-7.7.2 app/validators/url_validator.rb
udongo-7.7.1 app/validators/url_validator.rb
udongo-7.7.0 app/validators/url_validator.rb
udongo-7.6.2 app/validators/url_validator.rb
udongo-7.6.1 app/validators/url_validator.rb
udongo-7.6.0 app/validators/url_validator.rb
udongo-7.5.1 app/validators/url_validator.rb
udongo-7.5.0 app/validators/url_validator.rb
udongo-7.4.2 app/validators/url_validator.rb
udongo-7.4.1 app/validators/url_validator.rb
udongo-7.4.0 app/validators/url_validator.rb
udongo-7.3.5 app/validators/url_validator.rb
udongo-7.3.4 app/validators/url_validator.rb
udongo-7.3.3 app/validators/url_validator.rb
udongo-7.3.2 app/validators/url_validator.rb
udongo-7.3.1 app/validators/url_validator.rb
udongo-7.2.1 app/validators/url_validator.rb