From b49fffc5f6d4d582df3caabeda50a773c24ceef0 Mon Sep 17 00:00:00 2001 From: Gabriel Mazetto Date: Mon, 13 Aug 2012 19:34:30 -0300 Subject: [PATCH] Validates everytime by default, not only on save. --- lib/validates_cpf_cnpj.rb | 12 +++--------- 1 file changed, 3 insertions(+), 9 deletions(-) diff --git a/lib/validates_cpf_cnpj.rb b/lib/validates_cpf_cnpj.rb index c3b72a0..78f53ce 100644 --- a/lib/validates_cpf_cnpj.rb +++ b/lib/validates_cpf_cnpj.rb @@ -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