ec_validator/lib.rs
1//! Validation utilities for Ecuadorian government IDs and financial data.
2//!
3//! This crate provides validation for:
4//! - **Cédula de Identidad**: Ecuadorian national ID (10 digits)
5//! - **RUC**: Registro Único de Contribuyentes (taxpayer ID)
6//! - **IBAN**: International Bank Account Number for Ecuador
7//!
8//! # Features
9//!
10//! | Feature | Description | Default |
11//! |---------|-------------|---------|
12//! | `serde` | Enable serialization/deserialization derive macros | No |
13//! | `wasm` | Enable WebAssembly bindings with wasm-bindgen | No |
14//!
15//! # Validators
16//!
17//! | Module | Document Type | Length | Algorithm |
18//! |--------|-------------|--------|-----------|
19//! | [`cedula`] | Cédula de Identidad | 10 digits | Mod-10 |
20//! | [`ruc`] | RUC (Natural Person) | 13 digits | Mod-10 (first 10 as cédula) |
21//! | [`ruc`] | RUC (Juridical Entity) | 13 digits | Mod-11 |
22//! | [`ruc`] | RUC (Public Entity) | 13 digits | Mod-11 |
23//! | [`iban`] | IBAN (Ecuador) | 24 chars | Mod-97 |
24//!
25//! # Example
26//!
27//! ```rust
28//! use ec_validator::{cedula, ruc, iban};
29//!
30//! // Validate an Ecuadorian Cédula
31//! let cedula_result = cedula::validate("1713175071");
32//! assert!(cedula_result.is_ok());
33//!
34//! // Validate an Ecuadorian RUC
35//! let ruc_result = ruc::validate("1713175071001");
36//! assert!(ruc_result.is_ok());
37//!
38//! // Validate an Ecuadorian IBAN
39//! // Note: Use a properly formatted EC IBAN with valid check digits
40//! let iban_result = iban::validate("EC8912345678901234567890");
41//! // Result depends on check digit validity
42//! ```
43//!
44//! # Errors
45//!
46//! All validators return a [`ValidationError`] enum indicating the specific failure reason:
47//! - [`ValidationError::InvalidLength`] - Wrong number of digits/characters
48//! - [`ValidationError::InvalidCheckDigit`] - Check digit validation failed
49//! - [`ValidationError::InvalidProvinceCode`] - Invalid province code (not 01-24)
50//! - [`ValidationError::InvalidRucType`] - Invalid RUC type indicator
51//! - [`ValidationError::InvalidFormat`] - Invalid character format
52
53pub mod cedula;
54pub mod error;
55pub mod iban;
56pub mod ruc;
57
58pub use error::ValidationError;
59#[cfg(feature = "serde")]
60pub use error::ValidationErrorWithContext;
61
62#[cfg(feature = "wasm")]
63pub mod wasm;