rutcl

A set of chilean RUT utility functions for Deno

ci

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

import { format, validate } from "https://deno.land/x/rutcl/mod.ts";

Or import a single function from /lib/

import clean from "https://deno.land/x/rutcl/lib/clean.ts";

Functions

isValid(dirtyRut: string | number): boolean

Returns a boolean, true if RUT is valid, false otherwise.

import isValid from "https://deno.land/x/rutcl/lib/isValid.ts";

isValid(123456789); // => false

validate(dirtyRut: string | number): void

Throws an InvalidRUTException if RUT is not valid.

import validate from "https://deno.land/x/rutcl/lib/validate.ts";

validate(123456789); // => Throws InvalidRUTException

getDigit(partialDirtyRut: string | number): string

Returns a valid verification digit for given partial RUT

import getDigit from "https://deno.land/x/rutcl/lib/getDigit.ts";

getDigit("12345678"); // => "5"

format(dirtyRut: string | number): string

Returns a formatted RUT

import format from "https://deno.land/x/rutcl/lib/format.ts";

format("123456785"); // => "17.702.835-5"

clean(dirtyRut: string | number): string

Returns a clean RUT, only digits.

import clean from "https://deno.land/x/rutcl/lib/clean.ts";

clean("12.345.678-5"); // => "177028355"

CLI

TODO

Install CLI

TODO