Sha256: 429ba674119dda1c602b414387ebb016a5a06ece7b2906dc245371d1f7380d92

Contents?: true

Size: 429 Bytes

Versions: 2

Compression:

Stored size: 429 Bytes

Contents

# frozen_string_literal: true

module ActiveFields
  module Validators
    class DateValidator < BaseValidator
      private

      def perform_validation(value)
        if value.nil?
          errors << :required if options[:required]
        elsif value.acts_like?(:date)
          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/date_validator.rb
active_fields-1.0.0 lib/active_fields/validators/date_validator.rb