No description, website, or topics provided.
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Type Name Latest commit message Commit time
Failed to load latest commit information.
src fix(): the directive shouldn’t validate empty values Dec 16, 2016
test test(): add test for empty string case Dec 21, 2016
.editorconfig adds .editorconfig Oct 15, 2013
.gitignore ignores the lib folder Nov 29, 2013
.jshintrc improves library functions, adds tests Nov 29, 2013
.node-version fix(node): set node-version to 0.10 Apr 10, 2015
.travis.yml test(): run tests on sauce labs Mar 23, 2015
Gruntfile.js chore(): adds grunt release/publish tasks, closes #6 Dec 10, 2014 Updates license on readme Jan 23, 2015
bower.json chore(): bump up version Dec 28, 2016
karma-sauce.conf.js test(): run tests on sauce labs Mar 23, 2015

angular-rut Bower version Build Status

An Angular module with several components to handle Chilean RUT validation, cleaning and formatting. It includes:

  • ngRut: a directive to easily add validation, cleaning and formatting to any element with an associated ng-model value
  • rut: a filter to format valid RUTs with dots and dashes (11.111.111-1) in the view
  • RutHelper: a constant you can inject in your modules and exposes individual methods for validation, cleaning and formatting.


Just use Bower.

bower install angular-rut --save

Then, inject it into your application:

angular.module('MyApp', ['platanus.rut']);


Add the ng-rut directive to any element with an associated ng-model to automatically perform validation, cleaning and formatting.

<input ng-rut type="text" ng-model="model.rut">

The directive does the following:

  • It validates whether the input is a valid RUT (by using $setValidity),
  • passes a clean RUT (numbers and K only) to the model,
  • and formats the view by adding dots and dashes (11.111.111-1).


You can use the rut-format attribute to define when should the view be formatted:

  • live: Format as the RUT changes (e.g. as a user types into the input):
<input ng-rut rut-format="live" type="text">
  • blur: Format when the input is blurred:
<input ng-rut rut-format="blur" type="text">


Use it just like any Angular filter. It takes a (presumably valid) RUT, cleans and formats it.

{{ model.rut | rut }} 


Inject it as a dependency anywhere you like:

app.controller('RutCtrl', ['RutHelper', function(RutHelper){ ...

Then use it like so:

RutHelper.format('111111111'); // returns 11.111.111-1

There are three methods available:

  • RutHelper.clean(rut) strips every character except numbers and the letter K.
  • RutHelper.format(rut) cleans and formats the RUT number with dots and dashes (e.g 11.111.111-1).
  • RutHelper.validate(rut) returns a boolean indicating whether the given RUT is valid.


  1. Fork it
  2. Create your feature branch (git checkout -b my-new-feature)
  3. Commit your changes (git commit -am 'Add some feature')
  4. Push to the branch (git push origin my-new-feature)
  5. Create new Pull Request


Thank you contributors!


angular-rut is maintained by platanus.


It is free software and may be redistributed under the terms specified in the LICENSE file.