Sha256: f44c9bfae4f47ff545b5da39ee1a5a89d05a51862dfa818884b97b24aebbf6de

Contents?: true

Size: 349 Bytes

Versions: 2

Compression:

Stored size: 349 Bytes

Contents

# frozen_string_literal: true

# Validates that the given string has the correct rut syntax
class RutValidator < ActiveModel::EachValidator
  def validate_each(record, attribute, value)
    return if value.blank?
    return if Chilean::Rutify.valid_rut?(value)

    record.errors.add attribute, (options[:message] || "is not a valid rut")
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
chilean-rutify-1.1.0 lib/chilean/rutify/rut_validator.rb
chilean-rutify-1.0.0 lib/chilean/rutify/rut_validator.rb