Skip to content
Mihail Pozarski edited this page Mar 30, 2021 · 1 revision

Chilean::Rutify

Chilean Rutify is a Rails gem that makes rut validations and manipulation easy

Installation

Add this line to your application's Gemfile:

gem 'chilean-rutify'

And then execute:

bundle install

Or install it yourself as:

gem install chilean-rutify

Usage

You can use the available utility methods directly form the module:

    # using an example rut '36.408.368-8'
    rut = '36408368-8'
    Chilean::Rutify.normalize_rut(rut)
    # => "364083688"
    Chilean::Rutify.format_rut(rut)
    # => ""36.408.368-8"
    Chilean::Rutify.valid_rut?(rut)
    # => true
    Chilean::Rutify.valid_rut_verifier?(rut)
    # => true
    rut = "36408368"
    Chilean::Rutify.get_verifier(rut)
    # => "8"

You can also use the available validator as any other custom Rails validator:

class Person < ActiveRecord::Base
    validates :rut, presence: true, rut: true
end
Clone this wiki locally