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

Enable adding new validators by defining spring beans to complement the default Validator #3221

Open
taefi opened this issue Feb 10, 2025 · 4 comments
Labels
enhancement New feature or request hilla Issues related to Hilla needs design

Comments

@taefi
Copy link
Contributor

taefi commented Feb 10, 2025

Describe your motivation

At the moment, Hilla looks for a bean of type Validator, and if nothing found, it falls back the default from Jakarta API.
Most of the times, the defaults are needed, and the user wants to add some custom validators on top. Hilla can make it easier for the users to define as many custom validators as they want to complement the defaults, not to replace it.

Describe the solution you'd like

The main motivation of this enhancement issue is to the enable users introducing as many Validator beans to use them on top of the default from Jakarta API.

Then, if possible, the framework can expect an optional bean of type ValidatorFactory to enable users for completely opting out from the default, and introduce their own universal Validator.

Describe alternatives you've considered

No response

Additional context

No response

@taefi taefi added enhancement New feature or request hilla Issues related to Hilla labels Feb 10, 2025
@cromoteca
Copy link
Contributor

jakarta.validation.Validator does not support customization. It can be replaced with a custom implementation, that could wrap the default. This should be already possible in Hilla, by creating a Spring Bean that implements Validator.

@taefi
Copy link
Contributor Author

taefi commented Feb 10, 2025

I was mostly picturing it as looking up all the Validator beans, and validate parameters against all of them (including the default from Jakarta).

@taefi taefi changed the title Enable adding new validator by defining spring beans to complement the default Validator Enable adding new validators by defining spring beans to complement the default Validator Feb 10, 2025
@cromoteca
Copy link
Contributor

Implementing a Validator is quite unfriendly: https://jakarta.ee/specifications/bean-validation/3.1/apidocs/jakarta/validation/validator

@platosha
Copy link
Contributor

We need some proposal here to help implementing custom Validator that delegates to the default one.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request hilla Issues related to Hilla needs design
Projects
None yet
Development

No branches or pull requests

3 participants