Sha256: 2f531389682ddc102644cb1498b059f034c2b6ac8b73302bac54a58d8783f533

Contents?: true

Size: 439 Bytes

Versions: 1

Compression:

Stored size: 439 Bytes

Contents

# frozen_string_literal: true

module ActiveFields
  module Validators
    class IntegerValidator < BaseValidator
      private

      def perform_validation(value)
        if value.nil?
          errors << :required if active_field.required?
        elsif value.is_a?(Numeric)
          validate_minmax(value, min: active_field.min, max: active_field.max)
        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/integer_validator.rb