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

$formatNumber function returns NaN.00 when null in input #165

Closed
raj-work opened this issue Feb 28, 2018 · 4 comments
Closed

$formatNumber function returns NaN.00 when null in input #165

raj-work opened this issue Feb 28, 2018 · 4 comments
Labels

Comments

@raj-work
Copy link

Hi,

We are using formatNumber to return an amount field properly formatted. But instead we are getting a "-NaN.00".

Example:
$formatNumber($number(Account.Order[0].Product[2].Price), "#0.00")
returns "-NaN.00"
in the Account example of TryJSONata.

The expected behavior is it should return a null since the inside evaluation will return a null.

@andrew-coleman
Copy link
Member

Yep, that's a bug - thanks for reporting.

@raj-work
Copy link
Author

raj-work commented Mar 1, 2018

@andrew-coleman - thanks for the reply. I think you are missing the following check:
// undefined inputs always return undefined
if (typeof value === 'undefined') {
return undefined;
}

@mattbaileyuk
Copy link
Member

@raj-work Good spot! As you may have already seen, we're certainly open to taking pull requests.

@raj-work
Copy link
Author

raj-work commented Mar 5, 2018

@andrew-coleman , @mattbaileyuk - I updated the jsonata.js and merged my changes. Please let me know if you see any issues. Thanks.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants