globalizejs / globalizejs/globalize

Don't throw E_MISSING_PARAMETER on execution

Open
#530 13 comments 0 reactions 0 assignees View on GitHub
quick change
Dominant language
JavaScript
Stars
4.8k
Forks
585
PR merge metrics
No merged PRs in 30d

Description

Formatters and parsers throw E_MISSING_PARAMETER when any parameter is missing. For example:

``` js
Globalize('en').currencyFormatter()
// > currency: E_MISSING_PARAMETER: Missing required parameter `currency`.
```

It happens that it also throws on execution, for example:

``` js
var fmt = Globalize('en').currencyFormatter('USD');
fmt();
// > value: E_MISSING_PARAMETER: Missing required parameter `value`.
```

This could be an undesired validation, pointed out by #306. Also, it's a behavior not observed by native JavaScript, for example:

``` js
parseFloat();
// > NaN

var fmt = new Intl.DateTimeFormat('en');
fmt.format()
// > "10/10/2015"

fmt = new Intl.NumberFormat('en')
fmt.format()
// > "NaN"
```

Therefore, we could preserve the parameter validations for setup phase, i.e., when formatters or parsers are generated. But, we could drop them for execution and instead use a default like shown above.

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.