Sha256: d0cf17d3bd2382f532873bb2324dc173e592794e3be5c2f5d999fdb6be98419a

Contents?: true

Size: 323 Bytes

Versions: 2

Compression:

Stored size: 323 Bytes

Contents

class IpValidator < ActiveModel::EachValidator

  def validate_each(record, attribute, value)
    unless value =~ /^(?:(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.){3}(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)$/
      record.errors[attribute] << (options[:message] || I18n.t('yukonisuru.errors.messages.ip'))
    end
  end

end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
yukonisuru-1.0.0 lib/yukonisuru/validators/ip_validator.rb
yukonisuru-0.0.1 lib/yukonisuru/validators/ip_validator.rb