I want to dynamically change some of my own annotation error messages

Asked 2 years ago, Updated 2 years ago, 89 views

This is the continuation of the previous one.
I want to use my own annotation to separate error messages

suppress the default message in the context.disableDefaultConstraintViolation(); and
I was able to separate multiple messages in context.buildConstraintViolationWithTemplate.

We have created our own annotations with BeanValidation in Java, and we have come to the point where we have sent out multiple error messages.
Is there a way to dynamically change some of this error message?

I set the errors.properties to NOT_EXIST_END_TAG.msg = {invalidHTMLtag} should be set with end tag. I would like to set this {invalidHTMLtag} value.

Without other ConstraintValidatorContexts, I set it to ErrorContent as .metadata ("invalidHtmlTag", errorContent.get(0).getMetadata().get(").get("ERR_TAG") and added it to the Context to display it.

If anyone understands, please take care of me.

java annotations

2022-09-30 19:33

1 Answers

https://stackoverflow.com/questions/21486192/bean-validation-message-with-dynamic-parameter
I think I can solve it with this.
I tried to resolve it because I might need to use ValidationMessage.properties or I might not be able to give you any value.

https://qiita.com/neriudon/items/4329c80e676362c62f28
Here was a way to pass any parameters.

However, I couldn't fit my architecture because I have a habit.
So I tried it to some extent, but I couldn't reproduce it.

Now that we need an architecture-specific response, we're ready to answer this question.


2022-09-30 19:33

If you have any answers or tips


© 2024 OneMinuteCode. All rights reserved.