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

Validate messages #741

Open
JamesNK opened this issue Jan 29, 2020 · 12 comments
Open

Validate messages #741

JamesNK opened this issue Jan 29, 2020 · 12 comments
Labels
enhancement New feature or request
Milestone

Comments

@JamesNK
Copy link
Member

JamesNK commented Jan 29, 2020

Provide a way to validate messages, similar to ASP.NET Core MVC's model validation - https://docs.microsoft.com/aspnet/core/mvc/models/validation

Potential solution: https://github.com/envoyproxy/protoc-gen-validate. Either code generation of validation, or runtime validation.

@JamesNK JamesNK added the enhancement New feature or request label Jan 29, 2020
@JamesNK JamesNK added this to the Backlog milestone Jan 29, 2020
@AnthonyGiretti
Copy link

I have a temporary solution for now.

I forked a repo and improved it to make efficient validation. It's based on FluentValidation that injects
Validator in the DI and the validation is processed within an interceptor.
The client can get the error list from a strongly-typed model. Works only with gRPC, Have to improve this for gRPC-web.

Hope it could help!

https://github.com/AnthonyGiretti/grpc-aspnetcore-validator

@ansarizafar
Copy link

@JamesNK Is there any update on this issue? Code generated validation with https://github.com/envoyproxy/protoc-gen-validate is badly needed.

@JamesNK
Copy link
Member Author

JamesNK commented Apr 21, 2020

No. This isn't a high priority at the moment.

There is nothing stopping anyone from writing a library that inspects validation options defined in a proto file and uses them to validate Protobuf messages.

@Xaeco
Copy link

Xaeco commented Dec 17, 2020

I’m keen to assist with this issue.

In my Blazor WebAssembly projects I need to be able to validate user input against my proto3 models at runtime. Preferably using the EditForm component and DataAnnotationValidator.

Currently none of the projects I’ve seen work to that degree or they are missing dotnet support.

I haven’t contributed to GitHub repos before so will require some assistance on getting started and would appreciate help planning out what work would be involved.

@AnthonyGiretti
Copy link

AnthonyGiretti commented Dec 17, 2020 via email

@Xaeco
Copy link

Xaeco commented Dec 18, 2020

Thanks @AnthonyGiretti for your response.
I think decorating proto message declarations with validation conditions is a good way forward. Is this your approach?

@AnthonyGiretti
Copy link

AnthonyGiretti commented Dec 18, 2020 via email

@leblancmeneses
Copy link

One of the benefits of decorating proto message with validation annotations is the metadata will be available to other languages. There is probably already a set of open source annotations where we just need to implement some glue code for .net.

@Xaeco
Copy link

Xaeco commented Dec 18, 2020

As mentioned by @ansarizafar the https://github.com/envoyproxy/protoc-gen-validate repo is a great start. Just need to see if/how it can be extended for asp.net core and this repo.

@ziaulhasanhamim
Copy link

any updates on validation support?

@rafikiassumani-msft rafikiassumani-msft modified the milestones: Backlog, 7.0 Jan 24, 2022
@SIGAN
Copy link

SIGAN commented Jul 26, 2022

any update on validation support (8 months later, to keep the issue open)

@dystopiandev
Copy link

This really could use standardization.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
Status: No status
Development

No branches or pull requests

9 participants