Sha256: de9609449b40276f8eef8eada0b17d0d8fa76d5eea7f3296ccc4745ae90d89aa

Contents?: true

Size: 331 Bytes

Versions: 2

Compression:

Stored size: 331 Bytes

Contents

module ObjectValidator
  module Checks
    class Presence < Base
      def call
        presence = !method.nil? || method.respond_to?(:empty?) && !method.empty?
        return if value == presence
        errors.add(name, 'must not be Nil') if value
        errors.add(name, 'must be Nil') unless value
      end
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
object_validator-0.1.1 lib/object_validator/checks/presence.rb
object_validator-0.1.0 lib/object_validator/checks/presence.rb