Sha256: 73bad0805c4a42ac342ab2fce314c79aa5bce29e3dcfe5ac37c82e763e72e216

Contents?: true

Size: 457 Bytes

Versions: 1

Compression:

Stored size: 457 Bytes

Contents

# frozen_string_literal: true

class DomainNameValidator < ActiveModel::EachValidator
  def validate_each(record, attribute, value)
    return if ValidatesHost::DomainName.new(value).valid?

    ruby_prior_version_three =
      Gem::Version.new(RUBY_VERSION) < Gem::Version.new('3.0.0')

    if ruby_prior_version_three
      record.errors.add(attribute, :invalid, options)
    else
      record.errors.add(attribute, :invalid, **options)
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
validates_host-1.3.0 lib/validates_host/domain_name_validator.rb