Sha256: 8ccbc04712989ed54b5b3e7f4dc073e12fe016bce2e8cd245e480c55d11e2fc9

Contents?: true

Size: 601 Bytes

Versions: 2

Compression:

Stored size: 601 Bytes

Contents

# frozen_string_literal: true

module ActiveFields
  module Validators
    class DateTimeArrayValidator < BaseValidator
      private

      def perform_validation(value)
        unless value.is_a?(Array)
          errors << :invalid
          return
        end

        validate_size(value, min: options[:min_size], max: options[:max_size])

        value.each do |elem_value|
          if elem_value.acts_like?(:time)
            validate_minmax(elem_value, min: options[:min], max: options[:max])
          else
            errors << :invalid
          end
        end
      end
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
active_fields-1.1.0 lib/active_fields/validators/date_time_array_validator.rb
active_fields-1.0.0 lib/active_fields/validators/date_time_array_validator.rb