Permalink
Browse files

Revert "outline two ways to invoke a custom active model validator"

This reverts commit d163d3b.

Reason: The alternate approach can be documented in the guide and
not disrupt the existing flow in the readme.
  • Loading branch information...
1 parent 53f61ac commit 09298e42578740094130f4a6536b944a7733d7f1 @vijaydev vijaydev committed Nov 5, 2011
Showing with 1 addition and 9 deletions.
  1. +1 −9 activemodel/README.rdoc
View
@@ -162,21 +162,13 @@ modules:
{Learn more}[link:classes/ActiveModel/Validations.html]
* Custom validators
-
- class Person
- include ActiveModel::Validations
- validates_with HasNameValidator
- attr_accessor :name
- end
class Person
include ActiveModel::Validations
- validates :name, :has_name => true
+ validates_with HasNameValidator
attr_accessor :name
end
- You could use any of the two ways mentioned above to use a Custom Validator.
-
class HasNameValidator < ActiveModel::Validator
def validate(record)
record.errors[:name] = "must exist" if record.name.blank?

0 comments on commit 09298e4

Please sign in to comment.