class RutValidator
Validates that the given string has the correct rut syntax
Public Instance Methods
validate_each(record, attribute, value)
click to toggle source
# File lib/chilean/rutify/rut_validator.rb, line 5 def validate_each(record, attribute, value) if value.nil? || !value.is_a?(String) record.errors.add attribute, (options[:message] || "is a empty rut") elsif !Chilean::Rutify.valid_rut?(value) record.errors.add attribute, (options[:message] || "is not a valid rut") end end