Skip to Content
🎉 Rut.ts 3.4.0 is released! Check out Safe Mode and improved API.
DocumentationExamplesExamples

Examples

Practical examples for common use cases with rut.ts.

Common Patterns

Validation + Formatting

import { validate, format } from 'rut.ts' function processRut(input: string) { if (validate(input)) { return format(input) } throw new Error('Invalid RUT') }

Clean + Validate

import { clean, validate } from 'rut.ts' function normalizeAndValidate(input: string) { const cleaned = clean(input, { throwOnError: false }) return cleaned ? validate(cleaned) : false }

Decompose + Calculate

import { decompose, calculateVerifier } from 'rut.ts' function verifyRut(rut: string) { const { body, verifier } = decompose(rut) const calculated = calculateVerifier(body) return verifier === calculated }
Last updated on