Sha256: 432bdb1ea5220f0b0497162d567e83b08fdad306fe5fa634b90f53370324b73f

Contents?: true

Size: 449 Bytes

Versions: 1

Compression:

Stored size: 449 Bytes

Contents

# frozen_string_literal: true

module ActiveFields
  module Validators
    class TextValidator < BaseValidator
      private

      def perform_validation(value)
        if value.nil?
          errors << :required if active_field.required?
        elsif value.is_a?(String)
          validate_length(value, min: active_field.min_length, max: active_field.max_length)
        else
          errors << :invalid
        end
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
active_fields-0.2.0 lib/active_fields/validators/text_validator.rb