Hi, I have a pattern validation, but tried to avoid the long message setting the errormessage property without success.
any idea?
"ip": {
"type": "string",
"title": "Server IP or DNS",
"pattern": "^((?!-)[A-Za-z0-9-]{1,63}(?<!-)(\.[A-Za-z]{2,6})+|((25[0-5]|2[0-4][0-9]|1?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|1?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|1?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|1?[0-9][0-9]?)))$",
"errorMessage": " Hostname or ip invalid"
}
You normally don’t need to overwrite translateError as the also handed over translate is used within it anyway. See the i18n documentation for more information.
gallarl4_roche
(Gallardo Catalan, Luis {DISB~Sant Cugat Dia})
5
Yes, that is strange I tried all the combinations of message, but dont’ have luck with the pattern one…
gallarl4_roche
(Gallardo Catalan, Luis {DISB~Sant Cugat Dia})
6
I tried all this combinations
"infinity-ip": {
"type": "string",
"title": "Server IP or DNS",
"pattern": "^((?!-)[A-Za-z0-9-]{1,63}(?<!-)(\\.[A-Za-z]{2,6})+|((25[0-5]|2[0-4][0-9]|1?[0-9][0-9]?)\\.(25[0-5]|2[0-4][0-9]|1?[0-9][0-9]?)\\.(25[0-5]|2[0-4][0-9]|1?[0-9][0-9]?)\\.(25[0-5]|2[0-4][0-9]|1?[0-9][0-9]?)))$",
"error": {
"custom": "Invalid IP or DNS",
"defaultMessage": "Invalid IP or DNS",
"pattern": "Invalid IP or DNS",
"message": "Invalid IP or DNS"
}
There is a misunderstanding here. The documentation is describing how the keys of the translate function will look like when translating errors. There is no built-in mechanism to retrieve the properties from the JSON Schema.
Of course you CAN add the translations to the JSON Schema and then in your translate function you can inspect the schema and read the message from there if you like.
In any case, you will need to add a translate function to JSON Forms, as is described in the documentation.
1 Like
gallarl4_roche
(Gallardo Catalan, Luis {DISB~Sant Cugat Dia})
8