Module: SpanishCccValidator::ClassMethods
- Defined in:
- lib/spanish_ccc_validator.rb
Instance Method Summary collapse
Instance Method Details
#validate_spanish_ccc(*args) ⇒ Object
11 12 13 14 15 16 17 18 19 |
# File 'lib/spanish_ccc_validator.rb', line 11 def validate_spanish_ccc(*args) config = { :message => 'is invalid', :on => :save } config.update(args.pop) if args.last.is_a?(Hash) validates_each(args, config) do |record, arg, value| error_msg = config[:message].is_a?(Proc) ? config[:message].call : config[:message] record.errors.add(arg, error_msg) unless CustomCccValidator.validate(value) end end |