feat(isPostalCode): add `BD` locale by tanvirrb · Pull Request #2551 · validatorjs/validator.js
Conversation
This pull request includes updates to the README.md documentation, the isPostalCode validation logic, and the associated tests to add support for Bangladeshi postal codes.
Documentation update:
README.md: Added 'BD' (Bangladesh) to the list of supported locales for theisPostalCodefunction.
Validation logic update:
src/lib/isPostalCode.js: Added a new regular expression pattern for Bangladeshi postal codes to thepatternsobject.
Test update:
test/validators.test.js: Added test cases for Bangladeshi postal codes, including both valid and invalid examples.
Reference: Bangladehi postal code list in Wikipedia
Checklist
- PR contains only changes related; no stray files, etc.
- README updated (where applicable)
- Tests written (where applicable)
- References provided in PR (where applicable)
Codecov Report
All modified and coverable lines are covered by tests ✅
Project coverage is 100.00%. Comparing base (
d91af4b) to head (c967337).
Report is 1 commits behind head on master.
Additional details and impacted files
@@ Coverage Diff @@ ## master #2551 +/- ## ========================================= Coverage 100.00% 100.00% ========================================= Files 114 114 Lines 2535 2535 Branches 641 641 ========================================= Hits 2535 2535
☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.
🚀 New features to boost your workflow:
- ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
- 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.
WikiRik
changed the title
Add Bangladeshi postal code
feat(isPostalCode): add BD locale
WikiRik previously approved these changes Apr 9, 2025
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good! Just a small suggestion to simplify the regex
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters