Skip to content

Conversation

@herrkoch
Copy link

Prevents null reference error in parsedTime.toISOTime().replace() if parsedTime is invalid.

Fixes #349

Prevents null reference error in parsedTime.toISOTime().replace() if parsedTime is invalid
const parsedTime = TimeAdapter.parseTime(time, opts).setLocale(TimeAdapter.DEFAULT_LOCALE);

if (parsedTime.invalid) {
return null;
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd like to point out that I prefer null here over 'Invalid Time', otherwise the invalid value entered by the user will be replaced with 'Invalid Time' in the input field, which is not nice as the user won't be able to correct his/her mistake. I'd leave it to the developer to put form validation on the input field.

herrkoch and others added 2 commits October 16, 2020 17:37
invalid is not a public field of the luxon.DateTime class, instead isValid should be used
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Invalid time input from keyboard to form with timepicker causes an error 'Cannot read property 'replace' of null'

2 participants