globalizejs / globalizejs/globalize
Don't throw E_MISSING_PARAMETER on execution
- 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
Assessment
This issue has not been assessed yet.