I'm using MessageSource
of Spring to load errors messages from a .properties
file in classpath. My properties respect a certain "template" such as {Object}.{field}.{unrespectedConstraint}
Example :
userRegistrationDto.password.Size= Le mot de passe doit avoir au minimum 6 caractères.
userRegistrationDto.email.ValidEmail= Merci de saisir une addresse mail valide.
In case of refactoring (Changing the name of the class for example), I have to change my properties file in several places.
Is there any way to use a yaml file (messages.yml) as a ResourceBundle to obtain something like :
userRegistrationDto:
password:
Size: Le mot de passe doit avoir au minimum 6 caractères.
email:
ValidEmail: Merci de saisir une addresse mail valide.