def validate(resource)
      value = attribute_value(resource)

      if skip?(value) || valid_value?(value)
        nil
      else
        new_violation(resource, value)
      end
    end
def validate(resource)
      value = attribute_value(resource)

      if skip?(value) || valid_value?(value)
        nil
      else
        new_violation(resource, value)
      end
    end
Construct a validator. Capture the :if and :unless clauses when
 present.

 @param [String, Symbol] attribute_name
   The name of the attribute to validate.

 TODO: remove Hash as a value for :message
   (see Violation#[] in backwards.rb)

 @option [String, Hash] :message
   A custom message that will be used for any violations of this rule
 @option [Symbol, Proc] :if
   The name of a method (on the valiated resource) or a Proc to call
   (with the resource) to determine if the rule should be applied.
 @option [Symbol, Proc] :unless
   The name of a method (on the valiated resource) or a Proc to call
   (with the resource) to determine if the rule should *not* be applied.
 @option [Boolean] :allow_nil
   Whether to skip applying this rule on nil values
 @option [Boolean] :allow_blank
   Whether to skip applying this rule on blank values
 Validate the +resource+ arg against this Rule

 @param [Object] resource
   the target object to be validated

 @return [NilClass, Violation]
   NilClass if +resource+ is valid
   Violation with additional info if +resource+ is invalid