-
Hi everyone,
When there's an invalid Date, I want that the error message looks like The field doesn't match the date format "yyyy-MM-dd" nor "yyyy-MM-dd hh:mm:ss"but the translation doesn't work and I have "Key: ModifLeaveRequest.modifLeaveInfos.date_from' Error:Field validation for 'date_from' failed on the 'DateValidatorNil' tag" I would like to know what am I missing? Thank you very much. |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment
-
The trans variable was a global one, that I used to translate the errors. I discovered that the trans variable was still nil when I wanted to use it. Why? Because this line: This create a new local variable called trans, it doesn't initialize the global variable. cf:global error variable remains nil after initialization To fix it, I did that:
|
Beta Was this translation helpful? Give feedback.
The trans variable was a global one, that I used to translate the errors. I discovered that the trans variable was still nil when I wanted to use it.
Why? Because this line:
trans, found := uni.GetTranslator("en")
This create a new local variable called trans, it doesn't initialize the global variable. cf:global error variable remains nil after initialization
To fix it, I did that: