Cannot override ConstraintValidator default message

Description

Create interface MyCustomValidation and use as default message a message having the same message key name as the name of the just created interface (in our case the default message would be "{MyCustomValidation}").

If you then try to override the default message as follows it will fail:

constraintValidatorContext.buildConstraintViolationWithTemplate("some-other-message").addConstraintViolation();
constraintValidatorContext.disableDefaultConstraintViolation();

Environment

None

Activity

Show:
Alexandru Bondor
June 13, 2018, 5:38 PM
Edited
Alexandru Bondor
June 13, 2018, 5:37 PM

Thanks for pointing this out.

I tried writing a test for it but I'm failing on getting it set up properly. I need my default message inside MyCustomAnnotation to be a message key that will be resolved from a .properties file but I didn't succeed getting that into the test. Any clue on how to do that?

Guillaume Smet
June 13, 2018, 9:17 AM

Hi ,

Could you create a self contained test case from our test case template: https://github.com/hibernate/hibernate-test-case-templates/tree/master/validator ?

It's hard to say what's going wrong from your description.

Thanks!

Alexandru Bondor
June 12, 2018, 4:35 PM

This is my first ever created issue so please let me know if there isn't enough info about it or whether I placed it under the wrong project or whatever else might have been wrongly performed by myself. Thanks!

Assignee

Unassigned

Reporter

Alexandru Bondor

Labels

None

Feedback Requested

None

Feedback Requested By

None

backPortable

None

Suitable for new contributors

Yes, likely

Pull Request

None

backportDecision

None

backportReEvaluate

None

Affects versions

Priority

Minor