#[non_exhaustive]pub enum CnpjError {
Empty,
InvalidLength {
found: usize,
},
InvalidCharacter {
character: char,
position: u8,
expected: CharacterClass,
},
InvalidCheckDigits {
position: u8,
expected: u8,
found: u8,
},
RepeatedDigits,
}Expand description
The error returned when a Cnpj fails to parse or validate.
Each variant corresponds to one validation rule, in the order the rules are applied. See the module level documentation for the full rule list.
Variants (Non-exhaustive)§
This enum is marked as non-exhaustive
Empty
The input was an empty string.
InvalidLength
After stripping punctuation (., /, -, whitespace), the input did not contain exactly
14 meaningful characters.
InvalidCharacter
A character outside the allowed set was found at a given position.
Fields
expected: CharacterClassThe character class that was expected at this position.
InvalidCheckDigits
The Módulo 11 checksum did not match one of the two verification digits.
Fields
RepeatedDigits
All 14 characters were identical (e.g. "00000000000000").
Such inputs are structurally well-formed and can even satisfy the Módulo 11 checksum for certain repeated digits, but the Receita Federal never issues them; they are reliably placeholder or data-entry artifacts.
Trait Implementations§
impl Eq for CnpjError
Source§impl Error for CnpjError
impl Error for CnpjError
1.30.0 · Source§fn source(&self) -> Option<&(dyn Error + 'static)>
fn source(&self) -> Option<&(dyn Error + 'static)>
1.0.0 · Source§fn description(&self) -> &str
fn description(&self) -> &str
use the Display impl or to_string()