Skip to content

Internationalization (i18n)

zod-rs includes built-in locale support for validation error messages.

LocaleLanguage
Locale::EnEnglish (default)
Locale::ArArabic

Use the .local() method on validation errors to get localized messages:

use serde_json::json;
use zod_rs::prelude::*;
let schema = object()
.field("email", string().ends_with("@domain.com"))
.field("password", string().min(8))
.strict();
let input = json!({
"email": "john@example.com",
"password": "Strongpassword123"
});
match schema.safe_parse(&input) {
Ok(output) => println!("Valid: {output}"),
Err(err) => println!("{}", err.local(Locale::Ar)),
}

Want to add a new language or fix a translation? Contributions are welcome — open an issue or PR on GitHub.