meikidd / locale-code

locale code based on ISO-639-1 and ISO-3166-1
Other
36 stars 5 forks source link

Throw warning when input is invalid. #6

Closed jacklaurencegaray closed 4 years ago

jacklaurencegaray commented 4 years ago

Right now, most conversions return an empty string on invalid input. I think it would be helpful to log a warning message through the console in case of invalid input.

Let me know if this is fine. Would love to issue a PR for this feature.

meikidd commented 4 years ago

Hi Jack, thanks for the suggestion.

I don't think adding a warning message in this module would be a good idea. Think about if every module print warnings, our console would become very noisy and verbose.

Lower level modules usually only print necessary warnings for critical issues (such as api deprecate), input check can be done in upper level (applications). We have validateLanguageCode and validateCountryCode to help users check their input.