question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Support empty values without warning

See original GitHub issue

When used on a null value, logs warning into console:

Could not build a valid `moment` object from input.

I would assume that not all values are mandatory and would expect this filter to be permissive in this regard. Please remove the warning.

Possibly replace https://github.com/brockpetrie/vue-moment/blob/master/vue-moment.js#L33

if (!input || !date.isValid())

with

if (input && !date.isValid())

?

Issue Analytics

  • State:open
  • Created 6 years ago
  • Reactions:27
  • Comments:30 (1 by maintainers)

github_iconTop GitHub Comments

27reactions
ivoscommented, Apr 15, 2019

After some upgrade this filter stopped reflecting MomentJS locale. Creating this 9-line filter in main.js covered all my requirements, quit nagging me in the console AND respects the locale set in MomentJS:

import moment from 'moment'

Vue.filter('moment', function (value, format) {
  if (value === null || value === undefined || format === undefined) {
    return ''
  }
  if (format === 'from') {
    return moment(value).fromNow()
  }
  return moment(value).format(format)
})

Ditched this library and never looked back.

15reactions
rafaelmagalhaescommented, Oct 12, 2018

any updates on this ?

Read more comments on GitHub >

github_iconTop Results From Across the Web

“empty value” warning after updating PHP. - WordPress.org
Hello, After changing my PHP to up-to-date version, I get this warnings: Warning: Creating default object from empty value in…
Read more >
Unable to safely detect null value without nullable warnings
How can I safely determine if sheet.Id is not null? Update. This version actually compiles without warning. But I still don't understand why...
Read more >
Resolve nullable warnings | Microsoft Learn
Several compiler warnings indicate code that isn't null-safe. Learn how to address those warnings by making your code more resilient.
Read more >
SQL SERVER - Warning: Null value is Eliminated by an ...
Working with NULL's are always a challenge – not many developers understand how NULL works sometimes. In a related note, long back I...
Read more >
Report Definition Warning on Parameters to use Null if empty
Some of your filters are using a Page Reference with the "Use null if empty" option NOT selected. Please ensure that you do...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found