spain-vat-id

Crates.iospain-vat-id
lib.rsspain-vat-id
version0.1.2
sourcesrc
created_at2022-03-27 04:19:32.711444
updated_at2024-02-22 20:29:56.100566
descriptionSpanish VAT ID numbers validation/verification
homepagehttps://github.com/jsgm/spain-vat-id
repositoryhttps://github.com/jsgm/spain-vat-id
max_upload_size
id557153
size6,994
José Aguilera (jsgm)

documentation

README

spain-vat-id

Build Crate Minimum rustc version

A dead simple crate for validating/verifying Spanish VAT ID numbers written in Rust.

This crate allows you to easily check and verify the following ID numbers:

  • Documento Nacional de Identidad (DNI)
  • Número de Identificación Fiscal (NIF)
  • Número de Identificación de Extranjero (NIE)

Installation

cargo add spain-vat-id

Functions

nif_check_digit(val: u32) -> char
is_valid_nie(v: &str) -> (bool, String)
is_valid_nif(v: &str) -> (bool, String)
// NIF checking
let nif = "9874`457T";
let (valid, explain) = is_valid_nif(nif);
if !valid{
    println!("{}", explain);
    // Not valid: Char '`' at position 5 is not a number
}

Contributors

Special thanks to @dev-ardi for a rework and improvements.

References

Commit count: 12

cargo fmt