Closed thibaudcolas closed 6 years ago
Hi @thibaudcolas. I think this is something related to what is written here:
After that, if you call getMainMessage() or getFullMessage() (for nested), the message will be translated.
Note that getMessage() will keep the original message.
I just tried to use the latest version (1.1.23), to use templates and to set useTemplate
to false
and the result is the right one, so it seems that this is something related to https://github.com/Respect/Validation/pull/1047. I suppose the thing to do here is to update the respect/validation
package version and to create another release.
Hey @DavidePastore, thanks for taking the time to look into this. I haven't used the middleware or respect/Validation
with translators yet, so don't have any thoughts on how this getMainMessage
/ getFullMessage
difference might play into this.
If it helps I'm happy to submit a PR with the respect/Validation
upgrade. I'm using the upgraded version in my project and it seems to work well. Updating it directly within your project would also require fixing broken unit tests – I think they are just because Validation changed one of the rules' error message.
Yes, the tests need to be updated accordingly. Can you please check #38 and see if it contains the code you expect? Thanks 🐱
I've been trying to use templates for my validators with this middleware and
respect/validation
, and I have trouble understanding whatuseTemplate
does exactly.Looking at the middleware code:
https://github.com/DavidePastore/Slim-Validation/blob/c28d6e2545dab51c9c4330d4db1dc55a75632f56/src/Validation.php#L136-L139
useTemplate
just switches between only returning the main error message (the one for the last validator in the chain), and all messages. As far as I can tell there is nothing here related to templates, unless I'm missing something?I was wondering if this previous implementation might be in order to circumvent the issue fixed by https://github.com/Respect/Validation/pull/1047. With this fixed, I seem to be able to use templates as I would expect without needing the middleware's
useTemplate
.