Closed musaffa closed 7 years ago
You can configure it to accept empty dates to avoid the Invalid Date output: https://github.com/stefanpenner/ember-moment/blob/92a75466ce08715720204589e710481dd7b41dd7/README.md#global-allow-empty-dates
As for configuring the error message, "Invalid Date," that's handled internally within momentjs and I don't know off the top of my head if their is an API to configure it.
That said, I'd be happy to accept a pull request
I've already configured allowEmpty
to true
but Invalid date
message is still an issue.
@musaffa do you know what the value (empty string, null, or an invalid date string, etc.) you are passing into the helper is? Which helper are you using?
I'm using moment-format
helper. As this helper already handles invalid dates, I don't to want to handle invalid dates myself. All I want is the ability to override the default output message with invalid dates.
This answer in SO suggests using moment.js
' locale to override the message:
moment.updateLocale(moment.locale(), { invalidDate: "empty date" })
@musaffa Assuming you are on the latest version, I'd expect that to snippet to still work with ember-moment.
I tried but it didn't work. ember-moment
probably doesn't support updateLocale
.
@musaffa ember-cli-moment-shim (the thing you import moment
with) is a very thin wrapper around momentjs. So, ember-moment
really shouldn't be involved in the issue.
I would defer to opening an issue within momentjs if you need first-class support for changing this string.
A feature request.
Currently, if the date is invalid the template helper outputs
Invalid date
. The users might think there's something wrong in the data but if it is perfectly to valid to have empty dates. It is perhaps more desirable to display an empty""
orempty date
message to the user instead of showingInvalid date
. If there were a config option (global and local) to set a message which overrides thisInvalid date
message, this could have been easily solved. So if I setempty date
in that config setting, thisempty date
message will show up instead ofInvalid date
.Thanks.