Allow custom ValidationRule implementations to return multiple error messages
Maintainers usually reply within 1 day
Nobody has claimed this yet.
Assessment
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Newbie friendliness
- 64/100
- Issue type
- Feature
- Clarity
- Mostly clear
- Activity status
- Active
- Tech stack
- rust
- Domain
- backend-api-design
Research direction
Start by reading RuleError in laravel::validation and the Rule::failures and validate_matching_rules paths described in the issue. Check how existing custom validation rules return errors and how tests verify multiple messages for one field. Add a public way to return multiple messages, then confirm each appears in the field's error bag.
Written by the indexing model from the issue text.
Description
Need
Some validation rules check a single submitted field against an external verifier or composite policy that can report more than one failure reason at once (for example, CAPTCHA/bot verification APIs returning multiple error-codes, or multi-constraint domain validators).
In PHP Laravel, Illuminate\Contracts\Validation\ValidationRule::validate(string $attribute, mixed $value, Closure $fail) allows calling $fail(...) multiple times for the same field.
Current API gap
In laravel-rust 0.2.0, Rule::failures already returns Result<Vec<String>> internally (used by PasswordRule), and validate_matching_rules adds every message in that Vec to the field's error bag. However, laravel::validation::RuleError only exposes a single-message variant:
pub enum RuleError {
Invalid(String),
Failed(crate::Error),
}
So a custom ValidationRule implementation can only emit one validation error message per invocation.
Proposed small API
Either add a multi-message variant or constructor on RuleError (or a Field::reject_all helper):
// Option A: extend RuleError (or keep Invalid(String) and add InvalidMany(Vec<String>))
RuleError::invalid_many(messages: impl IntoIterator<Item = impl Into<String>>) -> Self
or allow Field to collect multiple rejected messages so custom rules can surface all failure reasons cleanly without workarounds.
- Dominant language
- Rust
- Stars
- 847
- Forks
- 174
- Avg merge
- 5h 40m
- Merged PRs (30d)
- 167
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
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from laravel/rust-framework
-
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
laravel/rust-framework#864 ·
Maintainers usually reply within 1 day
-
Case-sensitive contains, starts_with and ends_with that match % and _ literally on every databaseOpen
Difficulty 4/5 3-5 days Newbie friendliness 58/100
laravel/rust-framework#874 ·
Maintainers usually reply within 1 day
-
Difficulty 5/5 Over a week Newbie friendliness 35/100
laravel/rust-framework#873 ·
Maintainers usually reply within 1 day
-
Difficulty 4/5 3-5 days Newbie friendliness 58/100
laravel/rust-framework#872 ·
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 45/100
laravel/rust-framework#871 ·
Maintainers usually reply within 1 day
All issues in laravel/rust-framework
Similar issues
-
Difficulty 2/5 1-3 hours Newbie friendliness 76/100
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 83/100
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 65/100
neuralmagic/crucible#579 ·
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 62/100
eclipse-score/kyron#249 ·
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 67/100
seanmonstar/reqwest#3157 ·
Maintainers usually reply within 2 days