Support for #[validate(one_of(...))] for simple enum-like validations

Open
#375 2 comments 2 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

Difficulty
5/5
Estimated time
Over a week
Newbie friendliness
35/100
Issue type
Feature
Clarity
Mostly clear
Activity status
Stale
Tech stack
rust
Domain
backend

Research direction

The issue names no files, tests, or entry points; start by surveying the crate’s existing attribute validators and custom-function validation. Define the supported one_of behavior and validation cases, then add coverage demonstrating the proposed attribute syntax.

Written by the indexing model from the issue text.

Description

I’d like to have support for a #[validate(one_of(...))] attribute to simplify enum-like validations. Right now, I believe this can only be done in a custom function. A built-in validator like the following would be much cleaner.

#[validate(one_of("pending", "completed", "failed"))]
status: String

Similar functionality exists in marshmallow validate.OneOf

I’m open to feedback on this, but I wanted to see if this is something that would be aligned with the goals of this crate.

Dominant language
Rust
Stars
2.5k
Forks
190
PR merge metrics
No merged PRs in 30d

Getting set up

This project ships no dev container, Dockerfile or contributing guide, so setting up is up to you: start from its README, and see our first-contribution guide for the general steps.

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from Keats/validator

All issues in Keats/validator

Similar issues

More Rust issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.