Sha256: e2654e7e73277f4c0d7c382033657fd4f2aca1043de00fd1df489958b3e42917

Contents?: true

Size: 597 Bytes

Versions: 2

Compression:

Stored size: 597 Bytes

Contents

# frozen_string_literal: true

module ActiveFields
  module Validators
    class IntegerArrayValidator < 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.is_a?(Numeric)
            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/integer_array_validator.rb
active_fields-1.0.0 lib/active_fields/validators/integer_array_validator.rb