Stream: implementers
Topic: Validator error message
Igor (Dec 01 2021 at 13:19):
Hi!
Does the Validator have the ability to change the error message?
I am getting something like this about an invalid date:
"diagnostics":"Not a valid date (Invalid date/time format: \"19891021\": Expected character '-' at index 4 but found 1)"
I am wondering if it is possible to show the expected date format instead of the missing characters?
Thanks!
Grahame Grieve (Dec 01 2021 at 19:15):
well, we could, but the exepected date time format is defined in the specification, and it's yyyy-MM-dd
Igor (Dec 03 2021 at 08:07):
Thanks @Grahame Grieve !
Can I somehow override the datetime validator and return my own message?
Grahame Grieve (Dec 03 2021 at 11:06):
possibly. There's an internationalization framework. Or you can write a wrapper that modifies the property file as it loads. But what do you want it to say?
Igor (Dec 03 2021 at 11:59):
I just need to change the error message from
Invalid date/time format: \"19891021\": Expected character '-' at index 4 but found 1
to
Invalid date/time format: \"19891021\": Expected format: yyyy-MM-dd
Last updated: Apr 12 2022 at 19:14 UTC