@abstract-cl/rut-ts
v1.1.0
Published
NPM library to validate and format RUT (Chilean identification number)
Downloads
454
Readme
rut-ts
NPM library to validate and format RUT (Chilean identification number) a Chilean rut looks like this: 18.019.150-K
Important: You need to have the file ~/.npmrc with you github access token. Here you can find the documentation to configure.
Installation
Run this command on the root directory of the project ( only if you dont have a previous access token in this file ):
echo 'registry=https://npm.pkg.github.com/abstract-cl' >> .npmrc
With npm installed, run
$ npm install @abstract-cl/rut-ts
This will install the latest version of the library.
Usage
To import rut-ts in your file:
const { RUT } = require('@abstract/rut-ts');
Validation
To validate a rut
Rut.validate('18019150-K') -> True
Rut.validate('18.019.150K') -> True
Rut.validate('18.019.150-K') -> True
Rut.validate('0000000') -> False
Rut.validate('any-string-thats-not-a-rut') -> False
Clean RUT
To clean a rut
Rut.clean('18.019.150-K') -> '18019150K'
Rut.clean('18019150-K') -> '18019150K'
Rut.clean('18.019.50K') -> '18019150K'
Rut.clean('18019150K') -> '18019150K'
Rut.clean(undefined) -> undefined
Rut.clean(null) -> undefined