Function eu_vat_id::parse [−][src]
pub fn parse(vat_id: &str) -> Result<VATID, Error>
Parses a VAT ID to see if it has a valid syntax. It's an offline check, so it doesn't guarantee the VAT ID exists.
In case of success the function returns a VATID
struct, otherwise returns an Error
.
The function is case insensitive
You should only use this function if you need to know why the VAT ID is not valid, otherwise please use check()
.
Examples
match eu_vat_id::parse("IT00400770939") { Ok(vi) => println!("VAT ID is valid, state is {}", vi.state_iso), Err(e) => println!("VAT ID is invalid because: {:?}", e), }
Errors
- invalid-base-structure - VAT ID is not 2 letters + ??
- invalid-state - not an EU state
- invalid-local_vat_id - the VAT ID structure is not valid for the state specified