Sha256: 2fc6404660ddadfa9c0a05ec193c6e59729b7da550b5e2f026d647ba01df5143

Contents?: true

Size: 449 Bytes

Versions: 1

Compression:

Stored size: 449 Bytes

Contents

# frozen_string_literal: true

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