https://github.com/wachunei/rutcl
A set of chilean RUT utility functions for Deno
https://github.com/wachunei/rutcl
chile deno rut
Last synced: 9 months ago
JSON representation
A set of chilean RUT utility functions for Deno
- Host: GitHub
- URL: https://github.com/wachunei/rutcl
- Owner: wachunei
- License: mit
- Created: 2020-10-29T15:31:36.000Z (over 5 years ago)
- Default Branch: develop
- Last Pushed: 2021-02-03T00:43:33.000Z (over 5 years ago)
- Last Synced: 2025-09-16T09:00:17.038Z (9 months ago)
- Topics: chile, deno, rut
- Language: TypeScript
- Homepage: https://deno.land/x/rutcl
- Size: 26.4 KB
- Stars: 7
- Watchers: 5
- Forks: 1
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
rutcl
A set of chilean RUT utility functions for Deno
```ts
import {
clean,
format,
getDigit,
isValid,
validate,
} from "https://deno.land/x/rutcl/mod.ts";
try {
validate("123456789");
} catch (error) {
console.error(error.message); // "RUT is not valid"
}
isValid("123456785"); // => true
getDigit(12345678); // => "5"
clean("12.345.678-5"); // => "123456785"
format("123456785"); // => "12.345.678-5"
```
## Usage
Import functions from `https://deno.land/x/rutcl/mod.ts`
```ts
import { format, validate } from "https://deno.land/x/rutcl/mod.ts";
```
Or import a single function from `/lib/`
```ts
import clean from "https://deno.land/x/rutcl/lib/clean.ts";
```
## Functions
- [isValid](#functions-isvalid)
- [validate](#functions-validate)
- [getDigit](#functions-getdigit)
- [format](#functions-format)
- [clean](#functions-clean)
### `isValid(dirtyRut: string | number): boolean`
Returns a boolean, `true` if RUT is valid, `false` otherwise.
```ts
import isValid from "https://deno.land/x/rutcl/lib/isValid.ts";
isValid(123456789); // => false
isValid("18591404-6"); // => true
```
### `validate(dirtyRut: string | number): void`
Throws an `InvalidRUTException` if RUT is not valid.
```ts
import validate from "https://deno.land/x/rutcl/lib/validate.ts";
validate(123456789); // => Throws InvalidRUTException
validate("18591404-6"); // => undefined
```
### `getDigit(partialDirtyRut: string | number): string`
Returns a valid verification digit for given partial RUT
```ts
import getDigit from "https://deno.land/x/rutcl/lib/getDigit.ts";
getDigit("18591404"); // => "6"
```
### `format(dirtyRut: string | number): string`
Returns a formatted RUT
```ts
import format from "https://deno.land/x/rutcl/lib/format.ts";
format("185914046"); // => "18.591.404-6"
```
### `clean(dirtyRut: string | number): string`
Returns a clean RUT, only digits.
```ts
import clean from "https://deno.land/x/rutcl/lib/clean.ts";
clean("0018*591.404*6"); // => "185914046"
```
## CLI
`TODO`
### Install CLI
`TODO`