You validate search params and route data with the validation library your project already uses. Navi integrates four of them through mutually exclusive feature flags.
Choose one integration
Section titled “Choose one integration”| Feature | Crate |
|---|---|
validator |
validator |
garde |
garde |
validify |
validify |
valico |
valico |
Enable exactly one in your Cargo.toml:
[dependencies]navi-router = { path = "../navi/navi-router", features = ["garde"] }The validation surface
Section titled “The validation surface”All four integrations feed the same trait surface, re-exported from navi_router:
| Item | Role |
|---|---|
ValidateSearch |
Trait a search type implements to validate itself. |
ValidationResult |
Outcome of a validation pass. |
ValidationError |
A single validation failure. |
Implement ValidateSearch for your typed search struct (see Search Params), and the router consults it when matching navigations carry query data.
Verify
Section titled “Verify”Run the workspace tests for the feature you enabled:
cargo test -p navi-router --features gardeThe repository’s example-app ships a validation-test route directory with one page per integration (validator.rs, garde.rs, validify.rs, valico.rs) that you can open side by side.
Next steps
Section titled “Next steps”Search ParamsDeclare the typed search structs you validate here.
Core Types referenceValidateSearch, ValidationResult, and ValidationError.
