Sha256: 628d98ab024e548d6e6fdb5fcf2df9d6b1855133e56b3e48aeaf5d6ad442b45b

Contents?: true

Size: 607 Bytes

Versions: 2

Compression:

Stored size: 607 Bytes

Contents

# frozen_string_literal: true

module ActiveFields
  module Validators
    class TextArrayValidator < 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?(String)
            validate_length(elem_value, min: options[:min_length], max: options[:max_length])
          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/text_array_validator.rb
active_fields-1.0.0 lib/active_fields/validators/text_array_validator.rb