protoc-gen-validate icon indicating copy to clipboard operation
protoc-gen-validate copied to clipboard

feature request: javascript/typescript support

Open glerchundi opened this issue 8 years ago • 16 comments

Are you open for a PR supporting javascript/typescript?

glerchundi avatar Apr 13 '18 11:04 glerchundi

Totally!

rodaine avatar Nov 01 '18 19:11 rodaine

@glerchundi Are you planning to work on this?

4nte avatar Nov 02 '18 10:11 4nte

@antegulin probably in January but we need to first discuss the approach of course:

  • Only pure javascript?
  • Typescript is typically used in an Angular application which usually per-property validations were better than a one and only Validate method.
  • Maybe include this per-property in pure javascript and then type definitions on those?
  • What to do with RE2 validations? protocolbuffers/protobuf#53

And probably much more question, any thoughts?

glerchundi avatar Nov 06 '18 09:11 glerchundi

/cc @aberasarte

glerchundi avatar Nov 06 '18 09:11 glerchundi

any update on this ?

NeoCN avatar Mar 21 '19 07:03 NeoCN

Only pure javascript?

I think pure JS with TS stubs is the way to go, if that makes sense.

Typescript is typically used in an Angular application which usually per-property validations were better than a one and only Validate method. Maybe include this per-property in pure javascript and then type definitions on those?

For consistency with the rest of the languages, a single validate is preferred. While some of these implementations fail fast, if desired the function can gather all violations into a single error for per-property introspection. That said, if you want to go beyond that and provide per-property, I think that's fine too.

What to do with RE2 validations? protocolbuffers/protobuf#53

This isn't implemented yet, and is meant for validating that the value of a field is a valid regex, not that the value matches a regex. I'd not worry about this at the moment.

rodaine avatar Mar 22 '19 00:03 rodaine

@glerchundi @rodaine Any update on this? If any help is needed I am open for this...

Shivam010 avatar Jul 29 '19 08:07 Shivam010

As we want to have a full closed loop for the js code generation as well as the validation part of it, we're blocked on this: protocolbuffers/protobuf-javascript#65.

I think this can workaround by doing some seding after protoc, although it is a really awful solution :)

glerchundi avatar Jul 29 '19 11:07 glerchundi

Ok then...

Shivam010 avatar Jul 29 '19 11:07 Shivam010

Gently pining this ticket. Is it truly blocked on protocolbuffers/protobuf-javascript#65 it's hard to tell if that one is ever going to get fixed. Would it be possible to make some progress on this feature with the assumption that there are caveats (e.g. non-separability of the generated code modules)? Maybe even support by targeting another proto JS or TS generator?

smorel-plenty avatar Sep 16 '20 18:09 smorel-plenty

Watching..

buzzdan avatar Dec 02 '20 18:12 buzzdan

@glerchundi do you think theres any way around protocolbuffers/protobuf-javascript#65 ?

buzzdan avatar Jan 13 '21 14:01 buzzdan

Gently pining this ticket. Is it truly blocked on protocolbuffers/protobuf-javascript#65 it's hard to tell if that one is ever going to get fixed. Would it be possible to make some progress on this feature with the assumption that there are caveats (e.g. non-separability of the generated code modules)? Maybe even support by targeting another proto JS or TS generator?

We can target the one that we created. We have the ability to iterate quicker than any other plugin out there. I am ready to implement the validation runtime here and get it working with https://github.com/thesayyn/protoc-gen-ts

The only thing that I need right now, a runtime implemented here.

https://github.com/thesayyn/protoc-gen-ts/discussions/65

thesayyn avatar Jun 30 '21 11:06 thesayyn

Would love to see a js/ts implementation

loeffel-io avatar Apr 30 '22 19:04 loeffel-io

@thesayyn any updates on this one ?

buzzdan avatar Jul 13 '22 14:07 buzzdan

For anyone interested, this project (not mine), maps protoc-gen-validate grammar to an Open API spec, which then generates validation code. It's not perfect, but at least an option for anyone waiting on this to be resolved. https://github.com/kollalabs/protoc-gen-openapi

derekperkins avatar Sep 06 '22 23:09 derekperkins

actually i thought that buf (and connect-web) is primarly here to make the perfect support for web/java/typescriprt and grpc. Now i wonder why we don't have validation and a language such as go ?!? is preferred ?

nickwinger avatar Apr 11 '23 13:04 nickwinger

just for reference https://github.com/bufbuild/connect-es/issues/270

SpareShade avatar May 01 '23 03:05 SpareShade

Thanks for your feature request for TypeScript support. We appreciate your interest in enhancing the usability of pgv.

I wanted to let you know that we're actively working on adding TypeScript support in the protovalidate project. While this won't be implemented in protoc-gen-validate, we're excited about the possibilities it will bring to the Protobuf ecosystem.

With that said, I'll be closing this issue as we're addressing it in the protovalidate repository. If you have any more suggestions or questions, feel free to drop them our way.

elliotmjackson avatar Aug 10 '23 17:08 elliotmjackson