Sha256: 3ebd340c0e686d9ffaff7d3d18447dc27feacc425788cbc02fb6f556937eaa5c
Contents?: true
Size: 666 Bytes
Versions: 9
Compression:
Stored size: 666 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) Spree::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 = record.class.columns_hash[attribute.to_s].limit 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
9 entries across 9 versions & 1 rubygems