Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added postal code for nepal #1317

Merged
merged 2 commits into from
May 27, 2020
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion es/lib/isPostalCode.js
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ var patterns = {
MT: /^[A-Za-z]{3}\s{0,1}\d{4}$/,
NL: /^\d{4}\s?[a-z]{2}$/i,
NO: fourDigit,
NP: /^(10|21|22|32|33|34|44|45|56|57)\d{3}$|^(977)$/i,
NZ: fourDigit,
PL: /^\d{2}\-\d{3}$/,
PR: /^00[679]\d{2}([ -]\d{4})?$/,
Expand All @@ -59,7 +60,7 @@ var patterns = {
ZM: fiveDigit
};
export var locales = Object.keys(patterns);
export default function (str, locale) {
export default function isPostalCode(str, locale) {
assertString(str);

if (locale in patterns) {
Expand Down
5 changes: 3 additions & 2 deletions lib/isPostalCode.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.default = _default;
exports.default = isPostalCode;
exports.locales = void 0;

var _assertString = _interopRequireDefault(require("./util/assertString"));
Expand Down Expand Up @@ -52,6 +52,7 @@ var patterns = {
MT: /^[A-Za-z]{3}\s{0,1}\d{4}$/,
NL: /^\d{4}\s?[a-z]{2}$/i,
NO: fourDigit,
NP: /^(10|21|22|32|33|34|44|45|56|57)\d{3}$|^(977)$/i,
NZ: fourDigit,
PL: /^\d{2}\-\d{3}$/,
PR: /^00[679]\d{2}([ -]\d{4})?$/,
Expand All @@ -72,7 +73,7 @@ var patterns = {
var locales = Object.keys(patterns);
exports.locales = locales;

function _default(str, locale) {
function isPostalCode(str, locale) {
(0, _assertString.default)(str);

if (locale in patterns) {
Expand Down
1 change: 1 addition & 0 deletions src/lib/isPostalCode.js
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ const patterns = {
MT: /^[A-Za-z]{3}\s{0,1}\d{4}$/,
NL: /^\d{4}\s?[a-z]{2}$/i,
NO: fourDigit,
NP: /^(10|21|22|32|33|34|44|45|56|57)\d{3}$|^(977)$/i,
NZ: fourDigit,
PL: /^\d{2}\-\d{3}$/,
PR: /^00[679]\d{2}([ -]\d{4})?$/,
Expand Down
16 changes: 16 additions & 0 deletions test/validators.js
Original file line number Diff line number Diff line change
Expand Up @@ -7962,6 +7962,22 @@ describe('Validators', () => {
'3997 GH',
],
},
{
locale: 'NP',
valid: [
'10811',
'32600',
'56806',
'977',
],
invalid: [
'11977',
'asds',
'13 32',
'-977',
'97765',
],
},
{
locale: 'PL',
valid: [
Expand Down