1.1.0 • Published 1 year ago

@abstract-cl/rut-ts v1.1.0

Weekly downloads
-
License
ISC
Repository
github
Last release
1 year ago

rut-ts

Actions Status Actions Status Actions Status

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

Credits

1.1.0

1 year ago

1.0.2

2 years ago