Sha256: f9e98546c901dda784d0bb06d18fffa030019a0dd78e70b7c43962dc5a2cb5a0
Contents?: true
Size: 824 Bytes
Versions: 24
Compression:
Stored size: 824 Bytes
Contents
## # Validates a field based on the maximum length of the underlying DB field, if there is one. class DbMaximumLengthValidator < ActiveModel::EachValidator def validate_each(record, attribute, value) ActiveSupport::Deprecation.warn(<<-DEPRECATION, caller) `DbMaximumLengthValidator` is deprecated and will be removed in Spree 5.0. Please remove any `db_maximum_length: true` validations from your codebase DEPRECATION limit = if defined?(Globalize) record.class.translation_class.columns_hash[attribute.to_s].limit else record.class.columns_hash[attribute.to_s].limit end value = record[attribute.to_sym] if value && limit && value.to_s.length > limit record.errors.add(attribute.to_sym, :too_long, count: limit) end end end
Version data entries
24 entries across 24 versions & 1 rubygems