Sha256: 695b6ec52d395405a9ea4f4991f0c662dfec90a735a61a54ab62939dfdca9231

Contents?: true

Size: 433 Bytes

Versions: 1

Compression:

Stored size: 433 Bytes

Contents

# frozen_string_literal: true

module ActiveFields
  module Validators
    class DateValidator < BaseValidator
      private

      def perform_validation(value)
        if value.nil?
          errors << :required if active_field.required?
        elsif value.is_a?(Date)
          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/date_validator.rb