0.01
No commit activity in last 3 years
No release in over 3 years
Formato y validacion de RUT Chileno
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies

Development

~> 0.10.4
>= 3.2.1, ~> 3.2
 Project Readme

rut-chileno

ruby gem to validate and format chilean R.U.T.

install as ruby gem

	$ gem install chilean_rut

or add to Gemfile in Ruby on Rails

	gem 'chilean_rut'

then

	$ bundle install

One example use could be in a validator class

class RUTValidator < ActiveModel::Validator
  require 'chilean_rut'
  def validate(record)
    unless RUT::validate(record.rut)
      record.errors[:rut] << I18n.t(:invalid_rut)
    end
  end
end

which is then referenced from a model

class Person < ActiveRecord::Base
  validates_with RUTValidator
end

class functions

require 'chilean_rut'

rut = '55.555.555-5'
puts RUT::validate(rut) ? 'VALIDO' : 'NO VALIDO' # VALIDO
puts RUT::format(rut) # 55.555.555-5
puts RUT::remove_format(rut) # 555555555
puts RUT::remove_points(rut) # 55555555-5
puts RUT::remove_hyphens(rut) # 55.555.5555

based on jQuery library by Joaquin Nuñez

http://joaquinnunez.cl/jQueryRutPlugin/