Skip to content

Commit

Permalink
Making isPhone country default to US
Browse files Browse the repository at this point in the history
  • Loading branch information
ianwalter committed Jun 11, 2021
1 parent 63c96a0 commit 41cef5a
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 1 deletion.
5 changes: 5 additions & 0 deletions .changeset/giant-pans-relax.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@ianwalter/nrg-validation": patch
---

Making isPhone country default to US
2 changes: 1 addition & 1 deletion packages/nrg-validation/lib/validators.js
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ isStrongPassword.validate = function validateStrongPassword (password, inputs) {
}
}

export function isPhone (input, country) {
export function isPhone (input, country = 'US') {
return resultIsValid(isPhone.validate(input, country))
}
isPhone.validate = function validatePhone (input, country) {
Expand Down
1 change: 1 addition & 0 deletions packages/nrg-validation/tests/validators.tests.js
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@ test('isEmail', t => {
test('isPhone', t => {
t.expect(isPhone('617-777-9501', 'US')).toBe(true)
t.expect(isPhone('+16177779501')).toBe(true)
t.expect(isPhone('2018889999')).toBe(true)
t.expect(isPhone('07011 123456', 'GB')).toBe(true)
t.expect(isPhone('340 777 9501', 'US')).toBe(true)
t.expect(isPhone('(787) 777-9501', 'US')).toBe(true)
Expand Down

0 comments on commit 41cef5a

Please sign in to comment.