You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When trying to write validations for multiple locales, it would be nice to be able to check if validation is supported for the locale in question. Currently the locale specific validation functions just return false if an unsupported locale is provided, so if I want to differentiate between a failed validation and an unknown locale then I have to cross-reference the list of supported locales for that validator. Right now, none of these supported locales lists are exported, so it would have to be handled entirely by clietn code and would end up being stale, etc.
The ideal option might be to throw "Unsupported locale" or something similar instead of just returning false, though that would break backwards compatibility for existing users...
Alternatively, adding a way for consumers of validator.js to check which locales are supported for validation would allow people to intelligently handle these failures.
If the list of supported locales is consistent between all locale specific validation functions, a simple isLocaleSupported validator may be sufficient. Otherwise, providing exports of the different supported locale lists would be a decent start.
The text was updated successfully, but these errors were encountered:
The ideal option might be to throw "Unsupported locale" or something similar instead of just returning false, though that would break backwards compatibility for existing users...
I think this is the way to go, and I'd be happy to accept a PR with this change. It'd be a breaking change but I can bump the major as necessary.
When trying to write validations for multiple locales, it would be nice to be able to check if validation is supported for the locale in question. Currently the locale specific validation functions just return false if an unsupported locale is provided, so if I want to differentiate between a failed validation and an unknown locale then I have to cross-reference the list of supported locales for that validator. Right now, none of these supported locales lists are exported, so it would have to be handled entirely by clietn code and would end up being stale, etc.
The ideal option might be to throw "Unsupported locale" or something similar instead of just returning false, though that would break backwards compatibility for existing users...
Alternatively, adding a way for consumers of validator.js to check which locales are supported for validation would allow people to intelligently handle these failures.
If the list of supported locales is consistent between all locale specific validation functions, a simple isLocaleSupported validator may be sufficient. Otherwise, providing exports of the different supported locale lists would be a decent start.
The text was updated successfully, but these errors were encountered: