Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to put validation on an array member in a Query Parameter? #907

Open
stevenj opened this issue Oct 25, 2024 · 0 comments
Open

How to put validation on an array member in a Query Parameter? #907

stevenj opened this issue Oct 25, 2024 · 0 comments
Labels
question Further information is requested

Comments

@stevenj
Copy link

stevenj commented Oct 25, 2024

I have a query parameter defined like so:

        #[oai(validator(max_items = "10"))]
        Query(fragment_ids): Query<Vec<FragmentId>>,

FragmentId is a NewType, defined as:

#[derive(NewType)]
#[oai(example = true)]
/// Unique ID of a fragment.
pub(crate) struct FragmentId(String);

impl Example for FragmentId {
    fn example() -> Self {
        Self("0x7db6f91f3c92c0aef7b3dd497e9ea275229d2ab4dba6a1b30ce6b32db9c9c3b2".into())
    }
}

How do I set the maxLength and pattern properties on this string type that's inside the array?

I want pattern to enforce the hex string, and length to enforce the maximum size of this id.

@stevenj stevenj added the question Further information is requested label Oct 25, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Further information is requested
Projects
None yet
Development

No branches or pull requests

1 participant