def rule(field, definition)
      field = field.to_sym
      rules[field] = [] if rules[field].nil?

      begin
        if definition.respond_to?(:each_pair)
          add_parameterized_rules(field, definition)
        elsif definition.respond_to?(:each)
          definition.each do |item|
            if item.respond_to?(:each_pair)
              add_parameterized_rules(field, item)
            else
              add_single_rule(field, item)
            end
          end
        else
          add_single_rule(field, definition)
        end
      rescue NameError => e
        raise InvalidRule.new(e)
      end
      self
    end
def rule(field, definition)
      field = field.to_sym
      rules[field] = [] if rules[field].nil?

      begin
        if definition.respond_to?(:each_pair)
          add_parameterized_rules(field, definition)
        elsif definition.respond_to?(:each)
          definition.each do |item|
            if item.respond_to?(:each_pair)
              add_parameterized_rules(field, item)
            else
              add_single_rule(field, item)
            end
          end
        else
          add_single_rule(field, definition)
        end
      rescue NameError => e
        raise InvalidRule.new(e)
      end
      self
    end
Define a rule for this object

 The rule parameter can be one of the following:

 * a symbol that matches to a class in the Validation::Rule namespace
  * e.g. rule(:field, :not_empty)
 * a hash containing the rule as the key and it's parameters as the values
  * e.g. rule(:field, :length => { :minimum => 3, :maximum => 5 })
 * an array combining the two previous types