Sha256: 318fd93481f2793e8a8d8130e5f5fe70d6b8f51f568e58a98f7e6711bc94a9d9

Contents?: true

Size: 433 Bytes

Versions: 2

Compression:

Stored size: 433 Bytes

Contents

# frozen_string_literal: true

module ActiveFields
  module Validators
    class DateTimeValidator < BaseValidator
      private

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