Coder Social home page Coder Social logo

Comments (5)

elliotmjackson avatar elliotmjackson commented on May 29, 2024 1

Thanks for clarifying. For the performance considerations and the mechanics behind protovalidate, you can refer to our performance documentation. The current CEL-based implementation in protovalidate does indeed use reflection for validation.

Regarding your inquiry about VTProto-like unrolling to avoid reflection: it's entirely possible for someone to create a version that translates the CEL AST into concrete code. However, such an implementation is not in our immediate plans.

For now, if you're comfortable with it, you can continue using PGV. It's not being deprecated. However, we believe that protovalidate offers more advantages for most use cases.

I'll be closing this issue now. If you have any further questions or concerns, please don't hesitate to reopen or create a new issue.

from protovalidate.

delaneyj avatar delaneyj commented on May 29, 2024

I moved everything to https://github.com/bufbuild/protoc-gen-validate and changed tags/options/etc and see correct validation code generated.

if val := m.GetInputCount(); val <= 0 || val > 4096 {
		err := HyperParametersValidationError{
			field:  "InputCount",
			reason: "value must be inside range (0, 4096]",
		}
		if !all {
			return err
		}
		errors = append(errors, err)
	}

	if val := m.GetOutputCount(); val <= 0 || val > 4096 {
		err := HyperParametersValidationError{
			field:  "OutputCount",
			reason: "value must be inside range (0, 4096]",
		}
		if !all {
			return err
		}
		errors = append(errors, err)
	}
	```

from protovalidate.

elliotmjackson avatar elliotmjackson commented on May 29, 2024

Hi @delaneyj, i think theres some confusion here. There is no generated code with protovalidate, simply define the rules on your proto message like you've done, then pass the message through to the protovalidate.Validate method. protovalidate will handle the rest and return an error of the message does not conform to the defined rules.

I think what youve done here is define buf.validate.* options and then attempted to generate using the protoc-gen-validate plugin, which will not be able to interpret the options defined, resulting in no rules being generated for the type.

from protovalidate.

elliotmjackson avatar elliotmjackson commented on May 29, 2024

Hi @delaneyj, just checking in on this issue. Please let us know if you're still facing the problem, or if there's any additional information you can provide to assist us. Thanks!

from protovalidate.

delaneyj avatar delaneyj commented on May 29, 2024

I haven't ported back yet, so its using reflection at runtime for validation. Is there plans for something like VTProto were that can get unrolled to avoid the reflection?

from protovalidate.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.