Skip to content

Commit

Permalink
Validates everytime by default, not only on save.
Browse files Browse the repository at this point in the history
  • Loading branch information
brodock committed Aug 13, 2012
1 parent 7fc88c3 commit b49fffc
Showing 1 changed file with 3 additions and 9 deletions.
12 changes: 3 additions & 9 deletions lib/validates_cpf_cnpj.rb
Expand Up @@ -32,24 +32,18 @@ class CnpjValidator < CpfOrCnpjValidator

module HelperMethods
def validates_cpf(*attr_names)
configuration = { :on => :save }
configuration.update(attr_names.extract_options!)
raise ArgumentError, "You need to supply at least one attribute" if attr_names.empty?
validates_with CpfValidator, _merge_attributes(attr_names).merge(configuration)
validates_with CpfValidator, _merge_attributes(attr_names)
end

def validates_cnpj(*attr_names)
configuration = { :on => :save }
configuration.update(attr_names.extract_options!)
raise ArgumentError, "You need to supply at least one attribute" if attr_names.empty?
validates_with CnpjValidator, _merge_attributes(attr_names).merge(configuration)
validates_with CnpjValidator, _merge_attributes(attr_names)
end

def validates_cpf_or_cnpj(*attr_names)
configuration = { :on => :save }
configuration.update(attr_names.extract_options!)
raise ArgumentError, "You need to supply at least one attribute" if attr_names.empty?
validates_with CpfOrCnpjValidator, _merge_attributes(attr_names).merge(configuration)
validates_with CpfOrCnpjValidator, _merge_attributes(attr_names)
end
end
end
Expand Down

0 comments on commit b49fffc

Please sign in to comment.