Sha256: 8566320fb2cde31990f1df0b0246835e293b3da9f805e767b3ea8064c20a6094

Contents?: true

Size: 429 Bytes

Versions: 2

Compression:

Stored size: 429 Bytes

Contents

# frozen_string_literal: true

module ActiveFields
  module Validators
    class DecimalValidator < BaseValidator
      private

      def perform_validation(value)
        if value.nil?
          errors << :required if options[:required]
        elsif value.is_a?(Numeric)
          validate_minmax(value, min: options[:min], max: options[:max])
        else
          errors << :invalid
        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/decimal_validator.rb
active_fields-1.0.0 lib/active_fields/validators/decimal_validator.rb