Sha256: 8f30bf2de0d7a6f470b344e684290a0192994b2620d473dc98a2e01a7955c467

Contents?: true

Size: 439 Bytes

Versions: 1

Compression:

Stored size: 439 Bytes

Contents

# frozen_string_literal: true

module ActiveFields
  module Validators
    class DecimalValidator < 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/decimal_validator.rb