--- !ruby/object:RI::MethodDescription 
aliases: []

block_params: 
comment: 
- !ruby/struct:SM::Flow::P 
  body: Validate using method called on validated object. The method must to return either true, or a pair of [false, error message string], and is specified as a symbol passed with :method option.
- !ruby/struct:SM::Flow::P 
  body: This validator does support multiple fields being specified at a time, but we encourage you to use it with one property/method at a time.
- !ruby/struct:SM::Flow::P 
  body: Real world experience shows that method validation is often useful when attribute needs to be virtual and not a property name.
- !ruby/struct:SM::Flow::P 
  body: "@example [Usage]"
- !ruby/struct:SM::Flow::VERB 
  body: "  require 'dm-validations'\n\n class Page\n   include DataMapper::Resource\n\n   property :zip_code, String\n\n   validates_with_method :zip_code, :method =&gt; :in_the_right_location?\n\n   def in_the_right_location?\n     if @zip_code == &quot;94301&quot;\n       return true\n     else\n       return [false, &quot;You're in the wrong zip code&quot;]\n     end\n   end\n\n   # A call to valid? will return false and\n   # populate the object's errors with &quot;You're in the\n   # wrong zip code&quot; unless zip_code == &quot;94301&quot;\n end\n"
full_name: DataMapper::Validate::ValidatesWithMethod#validates_with_method
is_singleton: false
name: validates_with_method
params: (*fields)
visibility: public
