Sha256: decbd4de759bdd5e411b97ef71816d569c56d2567e01bc6d7af0ce4e9204bdba

Contents?: true

Size: 269 Bytes

Versions: 2

Compression:

Stored size: 269 Bytes

Contents

class HexValidator < ActiveModel::EachValidator

  def validate_each(record, attribute, value)
    unless value =~ /^#?([A-Fa-f0-9]{6}|[A-Fa-f0-9]{3})$/
      record.errors[attribute] << (options[:message] || I18n.t('yukonisuru.errors.messages.hex'))
    end
  end

end

Version data entries

2 entries across 2 versions & 1 rubygems

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