Sha256: cd10b7cbf8d716e7d6d739ee1676506f32b94d5f6f062f64a673db5de4f31fae

Contents?: true

Size: 656 Bytes

Versions: 1

Compression:

Stored size: 656 Bytes

Contents

module Humpyard
  module ActiveModel
    class PublishRangeValidator < ::ActiveModel::EachValidator
      def validate_each(record, attribute, value)
        if attribute == :display_from and not record.display_from.blank? and not record.display_until.blank? and record.display_until < record.display_from
          record.errors.add attribute, :cannot_be_after_display_until
        end
        if attribute == :display_until and not record.display_until.blank? and not record.display_from.blank? and record.display_until <= record.display_from
          record.errors.add attribute, :cannot_be_before_display_from
        end
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
humpyard-0.0.1 lib/humpyard/active_model/validators/publish_range.rb