Skip to content

Don't throw E_MISSING_PARAMETER on execution #530

@rxaviers

Description

@rxaviers

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

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

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

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:

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.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions