Sha256: aff7d03581745b0d690ca562e794c3741216f563261a38c64542a07beecd7cbe
Contents?: true
Size: 438 Bytes
Versions: 4
Compression:
Stored size: 438 Bytes
Contents
module RailsAdminSettings class HexColorValidator < ActiveModel::EachValidator def validate_each(record, attribute, value) record.errors[attribute] << (options[:message] || I18n.t('admin.settings.invalid_color')) unless value.blank? || self.class.matches?(value) end def self.matches?(value) return false unless value /^(?:[0-9a-f]{3})(?:[0-9a-f]{3})?$/i.match(value).nil? ? false : true end end end
Version data entries
4 entries across 4 versions & 1 rubygems