Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/ppbustamante/scala-stdnum
A Scala library to provide functions to handle, parse and validate standard numbers.
https://github.com/ppbustamante/scala-stdnum
chilean-rut cuit curp dni rfc rut scala scala3
Last synced: 5 days ago
JSON representation
A Scala library to provide functions to handle, parse and validate standard numbers.
- Host: GitHub
- URL: https://github.com/ppbustamante/scala-stdnum
- Owner: ppbustamante
- License: lgpl-2.1
- Created: 2022-08-02T05:02:30.000Z (over 2 years ago)
- Default Branch: main
- Last Pushed: 2023-11-19T03:21:12.000Z (12 months ago)
- Last Synced: 2023-11-20T04:01:29.448Z (12 months ago)
- Topics: chilean-rut, cuit, curp, dni, rfc, rut, scala, scala3
- Language: Scala
- Homepage:
- Size: 164 KB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# scala-stdnum
[![CI](https://github.com/ppbustamante/scala-stdnum/actions/workflows/scala.yml/badge.svg)](https://github.com/ppbustamante/scala-stdnum/actions/workflows/scala.yml)
A Scala library to parse, validate and reformat standard numbers and codes in different formats. It contains a large collection of number formats.
Basically any number or code that has some validation mechanism available or some common formatting is eligible for inclusion in this library.
## Available formats
Currently, this package supports the following formats:
- RUT (Rol Único Tributario, Chilean national tax number).
- DNI (Documento Nacional de Identidad, Argentinian national identity number).
- CUIT (Código Único de Identificación Tributaria, Argentinian tax number).
- CBU (Clave Bancaria Uniforme, Argentine bank account number).
- RFC (Registro Federal de Contribuyentes, Mexican tax number).
- CURP (Clave Única de Registro de Población, Mexican personal ID.)
- NIT (Número De Identificación Tributaria, Colombian identity code).
- CNPJ (Cadastro Nacional da Pessoa Jurídica, Brazilian company identifier).
- CPF (Cadastro de Pessoas Físicas, Brazilian national identifier).
- RIF (Registro de Identificación Fiscal, Venezuelan VAT number).These modules generally do not provide background information on the meaning and use of the specified numbers, only parsing and handling functions.
## Interface
All modules implement a common interface. For example for RUT validation:
```scala
import cl.mixin.stdnum.cl.RUTRUT.validate("39.232.415-1")
val res0: Either[ValidationError, String] = Right(392324151)RUT.validate("23.431.324-3")
val res1: Either[ValidationError, String] = Left(InvalidChecksum)
```Most of these modules implement the following functions:
- `validate()` validate the correctness of the passed number and return a compact representation of the number invalid
numbers are rejected with one of the exceptions from the stdnum.exceptions module
- `compact()` return a compact representation of the number or code this function generally does not do validation but
may raise exceptions for wildly incorrect numbers
- `format()` return a formatted version of the number in the preferred format this function generally expects to be
passed a valid number or codeApart from the above, the module may add extra parsing, validation or conversion functions.
## Requirements
The modules should not require any external Scala library and should be pure Scala. The modules are developed and tested with Scala 3.