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

Extract common parts that generate code to create an instance of ConstraintViolation #167

Open
yevhenii-nadtochii opened this issue Dec 2, 2024 · 0 comments

Comments

@yevhenii-nadtochii
Copy link
Contributor

On the one hand we have SetOnceConstraintViolation and on the other ErrorMessage.createViolation() with ErrorMessage.createCompositeViolation.

They are quite different, but should have the common base, which this issue suggests to extract. Another aspect of this issue it to create consistent instances of ConstraintViolation throughout the validation library.

The first implementation produces code that creates a ConstraintViolation for a specific option, for this reason it is relatively small. It uses our Expression API, and takes into account that the ConstraintViolation instance expects a printf string format along with a list of parameters for it.

The second implementation is coupled with Rules-based validation codegen. It introduces own entities like: ErrorMessages, ErrorMessage, Template. And something similar to our Expression API from ProtoData: Span, LiteralSpan, ExpressionSpan. Though, it uses Java Poet to "partially" prepare the code. Another aspect is that it doesn't return a printf string, instead it interpolates parameters right into the format string.

So, in the scope of this issue, the following should be done:

  1. Extract the common parts of ContraintValidation creation.
  2. Re-use them in SetOnceConstraintViolation and Rules codegen.
  3. Migrate the remaining code around to PSI/Expression API.
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

No branches or pull requests

1 participant