-
Notifications
You must be signed in to change notification settings - Fork 339
Being able to override attributeName #148
Comments
For those interested, I ended up writing my own field/label translate function based on my idea in the previous post. Here is the adapter. It's TypeScript code. I'm leaving it as is, with the french documentation.
And here is an example of how to use it:
Though, I still believe validate.js could use a parameter to override the attribute name. That would have allowed me not to have to write this tedious code, and give a little performance boost since all those back and forth translations wouldn't be necessary. |
I'll consider adding an attribute key mapper. |
+1 I am also in need of this. |
This looks like a duplicate of #69 |
I was able to work around this with by
Hope this helps someone
|
Can someone please add this feature? |
any update on this? :) |
Can we make outputting the key in the error optional so we can define a totally custom error message? |
Related to #69 |
@ansman what is the status? |
Hello,
I have the following problem: I would like to be able to override the attribute name in the error messages.
For example, I have a countryCurrency field in my form, that's a business term, but my application is in french, and the label displayed over the field is 'Devise du pays'.
Using validate.js, I get the error message 'CountryCurrency is invalid' (actually we translated the 'is invalid' part), which is at best not very pretty, but also can be confusing for our users.
I would like to be able to do this:
So I can have a nice error message 'Devise du pays is invalid'.
I realize the attribute name is not a constraint and has not much to do with it, but that's the most logical place I could find. Maybe you could rename the parameter 'contraints' to 'rules', which would make more sense if attributeName is added to it.
Writing this, I'm thinking that I could possibly do this:
But you see, I'm leveraging validate.js by linking it to redux-form. I suppose you're not familiar with it, but it happens that the errors object returned by default by validate.js (grouped) fits perfectly what redux-form is expecting. I'm doing this:
...and give validator to redux-form. That works very well, except for this attribute name problem.
I can see I'm not the only one having this problem:
#69 #102
But proposed solutions so far does not seem very nice to me.
I could do a PR of this if you're interested. I'm also considering to write a TypeScript definition for validate.js, since it's missing and would be useful.
The text was updated successfully, but these errors were encountered: