Sha256: e304c9c5fa339a5295cb5dcdcae6eb56b46adf40bbeb35703b8f54abf76dd748

Contents?: true

Size: 453 Bytes

Versions: 1

Compression:

Stored size: 453 Bytes

Contents

# frozen_string_literal: true

class HostNameValidator < ActiveModel::EachValidator
  def validate_each(record, attribute, value)
    return if ValidatesHost::HostName.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/host_name_validator.rb