Sha256: 2b31e47acdf587957e526e1cc2a7bbe8170154ce03d8e07e8a5dd9b5690bd08e
Contents?: true
Size: 498 Bytes
Versions: 1
Compression:
Stored size: 498 Bytes
Contents
class CountValidator < ActiveModel::Validations::LengthValidator MESSAGES = { :wrong_length => :count_invalid, :too_short => :count_greater_than_or_equal_to, :too_long => :count_less_than_or_equal_to }.freeze def initialize(options) options = options.reverse_merge(MESSAGES) super end def validate_each(record, attribute, value) existing_records = record.send(attribute).reject(&:marked_for_destruction?) super(record, attribute, existing_records) end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
apress-validators-0.1.0 | app/validators/count_validator.rb |