Sha256: b9fee511729d5ce75f899b062daef4e22afd8939995ade16b66e5293ccc93600

Contents?: true

Size: 255 Bytes

Versions: 11

Compression:

Stored size: 255 Bytes

Contents

module ActiveModel
  module Validations
    class HexColorValidator < EachValidator
      def validate_each(record, attribute, value)
        unless value =~ /\A(\h{3}){,2}\z/
          record.errors.add(attribute)
        end
      end
    end
  end
end

Version data entries

11 entries across 11 versions & 1 rubygems

Version Path
activevalidators-6.0.0 lib/active_validators/active_model/validations/hex_color_validator.rb
activevalidators-5.1.0 lib/active_validators/active_model/validations/hex_color_validator.rb
activevalidators-5.0.1 lib/active_validators/active_model/validations/hex_color_validator.rb
activevalidators-5.0.0 lib/active_validators/active_model/validations/hex_color_validator.rb
activevalidators-4.1.0 lib/active_validators/active_model/validations/hex_color_validator.rb
activevalidators-4.0.3 lib/active_validators/active_model/validations/hex_color_validator.rb
activevalidators-4.0.2 lib/active_validators/active_model/validations/hex_color_validator.rb
activevalidators-4.0.1 lib/active_validators/active_model/validations/hex_color_validator.rb
activevalidators-4.0.0 lib/active_validators/active_model/validations/hex_color_validator.rb
activevalidators-3.3.0 lib/active_validators/active_model/validations/hex_color_validator.rb
activevalidators-3.2.0 lib/active_validators/active_model/validations/hex_color_validator.rb