Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Document method for determining whether a moment() is valid #251

Closed
wolever opened this issue Apr 3, 2012 · 1 comment
Closed

Document method for determining whether a moment() is valid #251

wolever opened this issue Apr 3, 2012 · 1 comment

Comments

@wolever
Copy link

wolever commented Apr 3, 2012

Currently there doesn't seem to be any straight forward method of determining whether a moment() is valid or not (ex, because a parse failed).

Various methods (ex, isNaN(+moment("asdf"))) work, but it would be nice if there was a documented right way to do this.

I would propose:

moment.fn.valid = function() {
    return isNaN(+this);
}

But there is no doubt a better way.

@timrwood
Copy link
Member

timrwood commented Apr 3, 2012

Check out the discussion on #235

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

No branches or pull requests

2 participants