Skip to content
New issue

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

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

Already on GitHub? # to your account

Validate keys #94

Draft
wants to merge 2 commits into
base: main
Choose a base branch
from
Draft

Validate keys #94

wants to merge 2 commits into from

Conversation

jprochazk
Copy link
Owner

Part of #82 (comment)

Adds the keys modifier, which applies any rules onto the keys of a collection:

#[derive(garde::Validate)]
struct Key<'a> {
    #[garde(
        keys(length(min = 1)),  // apply to keys
        inner(length(min = 1)), // apply to values
    )]
    inner: HashMap<&'a str, &'a str>,
}

WIP:

  • Initial implementation in garde_derive + garde
  • Improve error messages for the keys modifier
    • It should somehow specify that the validation failure applies to the key, not the value

# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant