Sha256: 9720ca8d5768e0d82c141e3059e85800a0f02b00bee461187b10c42534398df6

Contents?: true

Size: 487 Bytes

Versions: 6

Compression:

Stored size: 487 Bytes

Contents

require 'applb/error'

module Applb
  class DSL
    module Checker
      private

      class ValidationError < Error
      end

      def required(name, value)
        if value
          case value
          when String
            invalid = value.strip.empty?
          when Array, Hash
            invalid = value.empty?
          end
        else
          invalid = true
        end

        raise ValidationError.new("`#{name}' is required") if invalid
      end
    end
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
applb-0.1.5.beta1 lib/applb/dsl/checker.rb
applb-0.1.4 lib/applb/dsl/checker.rb
applb-0.1.3 lib/applb/dsl/checker.rb
applb-0.1.2 lib/applb/dsl/checker.rb
applb-0.1.1 lib/applb/dsl/checker.rb
applb-0.1.0 lib/applb/dsl/checker.rb