tamasfe / aide

An API documentation library
Apache License 2.0
393 stars 62 forks source link

How to define min / max for ints/numbers Query params? #108

Closed itsbalamurali closed 7 months ago

itsbalamurali commented 7 months ago

How to define min / max for ints/numbers Query params?

y-haidar commented 7 months ago

As far as I have tested/read, schemars::JsonSchema have a #[validate(...)] attribute that matches validator::Validate, from the validator crate.

#[derive(JsonSchema)]
struct Example {
    #[validate(length(min = 5))]
    field: String,
    #[validate(range(min = 18, max = 20))]
    number: u32,
}

Was this what you needed?

itsbalamurali commented 7 months ago

Thanks @y-haidar !