Crates.io | spain-vat-id |
lib.rs | spain-vat-id |
version | 0.1.2 |
source | src |
created_at | 2022-03-27 04:19:32.711444 |
updated_at | 2024-02-22 20:29:56.100566 |
description | Spanish VAT ID numbers validation/verification |
homepage | https://github.com/jsgm/spain-vat-id |
repository | https://github.com/jsgm/spain-vat-id |
max_upload_size | |
id | 557153 |
size | 6,994 |
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:
cargo add spain-vat-id
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
}
Special thanks to @dev-ardi for a rework and improvements.