Sha256: 634cf1d505cbc25231d5c8425ae5d8aef7f9707e0f349865088f035700214826

Contents?: true

Size: 258 Bytes

Versions: 2

Compression:

Stored size: 258 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('errors.messages.hex'))
    end
  end

end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
flash_validators-3.0.1 lib/flash_validators/validators/hex_validator.rb
flash_validators-3.0.0 lib/flash_validators/validators/hex_validator.rb