Sha256: 8d4b0ff8460794b7a0ab660751ba6d7190d4290cd022a8e3fc41f4d22bc936d7

Contents?: true

Size: 667 Bytes

Versions: 4

Compression:

Stored size: 667 Bytes

Contents

module Compel
  module Validation

    class Condition

      attr_reader :value,
                  :options,
                  :value_type,
                  :option_value

      def self.validate(value, option_value, options = {})
        new(value, option_value, options).validate
      end

      def initialize(value, option_value, options = {})
        @value = value
        @value_type = options.delete(:type) || Coercion::Types::Any
        @option_value = option_value
      end

      def validate
        # result is an error message
        result = validate_value

        Validation::Result.new(value, value_type, result)
      end

    end

  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
compel-0.4.0 lib/compel/validation/conditions/condition.rb
compel-0.3.7 lib/compel/validation/conditions/condition.rb
compel-0.3.6 lib/compel/validation/conditions/condition.rb
compel-0.3.4 lib/compel/validation/conditions/condition.rb