Skip to content

Return all validation errors#20

Open
fenollp wants to merge 1 commit intolinka-cloud:mainfrom
fenollp:multierrs
Open

Return all validation errors#20
fenollp wants to merge 1 commit intolinka-cloud:mainfrom
fenollp:multierrs

Conversation

@fenollp
Copy link
Contributor

@fenollp fenollp commented Jun 3, 2025

Closes #6

WIP:

  • I'll do an Errors type that is a vector of Error as the encapsulation with prost_validate::Error rarely makes sense.
  • Should that Vec be boxing errors?
  • I'll split to a second trait when things start working

Any idea on what cargo invocation I can pull to show the final generated code? Looking inside ./target isn't helping. Thanks!

@Adphi
Copy link
Member

Adphi commented Jun 3, 2025

Should that Vec be boxing errors?

I don't think that needs to be dynamic.

Any idea on what cargo invocation I can pull to show the final generated code?

I used cargo expand and a useless test to see the output:

mod tests {
use super::*;
#[test]
fn tests() {
let input = quote! {
pub struct WrapperRequiredFloat {
#[prost(message, optional, tag = "1")]
#[validate(name = "tests.harness.cases.WrapperRequiredFloat.val")]
#[validate(r#type(float(gt = 0.0)), message(required = true))]
pub val: ::core::option::Option<::pbjson_types::FloatValue>,
}
};
println!("{}", derive_2(input));
}
}

@fenollp fenollp force-pushed the multierrs branch 5 times, most recently from b23307d to faa2bf1 Compare June 5, 2025 16:38
@fenollp fenollp marked this pull request as ready for review June 5, 2025 16:52
@fenollp fenollp requested a review from Adphi June 5, 2025 16:53
Copy link
Member

@Adphi Adphi left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you very much 😀

Maybe we need to add the method in the example and update the README accordingly.

It also needs to be implemented in the prost-reflect-validatecrate.

Signed-off-by: Pierre Fenoll <pierrefenoll@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Support returning multiple validation errors

2 participants