| Crates.io | socrates_rs |
| lib.rs | socrates_rs |
| version | 1.1.0 |
| created_at | 2020-09-30 13:49:27.318975+00 |
| updated_at | 2025-01-03 13:15:49.426442+00 |
| description | Validate and Extract information from National Identification Numbers. |
| homepage | |
| repository | https://github.com/reducktion/socrates-rs |
| max_upload_size | |
| id | 294612 |
| size | 290,715 |
use socrates_rs;
assert_eq!(true, socrates_rs::validate_id("14349483 0 ZV3", socrates_rs::country::Code::PT));
let citizen = socrates_rs::extract_information("2820819398814 09", socrates_rs::country::Code::FR).unwrap();
assert_eq!(citizen.gender, 'F');
assert_eq!(citizen.year_of_birth, 1982);
assert_eq!(citizen.month_of_birth.unwrap(), 8);
assert_eq!(citizen.place_of_birth.unwrap(), "Corrèze");
let generated_id = socrates_rs::generate_id(&citizen, socrates_rs::country::Code::DK).unwrap();
assert_eq!(true, socrates_rs::validate_id(generated_id, socrates_rs::country::Code::DK));
This rust crate is a port of the php package socrates.
socrates-rs allows you to validate and retrieve personal data from National Identification Numbers across the world with the goal of eventually supporting as many countries in the world as possible.
Some countries also encode personal information of the citizen, such as gender or the place of birth. This package allows you to extract that information in a consistent way.
This crate can be useful for many things, such as validating a user's ID for finance related applications or verifying a user's age without asking for it explicitly. However, we recommend you review your country's data protection laws before storing any information.
Functions are available with socrates-rs:
validate_id which returns a boolean indicating if an id is valid in a specific countryextract_information which returns an Optional Citizen with information retrievable from the identifier (gender, date of birth, ...)generate_id which returns a valid identifier for the provided CitizenThe list of supported countries is available via the Country::code enum.
Did you find a problem in any of the algorithms? Do you know how to implement a country which we have missed? Are there any improvements that you think should be made to the codebase? Any help is appreciated! Take a look at our contributing guidelines.
The MIT License (MIT). Please see License File for more information.