-
Notifications
You must be signed in to change notification settings - Fork 54
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(TDOPS-5386/utils): remove phone validation as not in use (#4972)
* fix(TDOPS-5386/utils): remove phone validation as not in use * chore: generate chnageset * fix: remove PHONE import
- Loading branch information
Showing
5 changed files
with
20 additions
and
67 deletions.
There are no files selected for viewing
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
--- | ||
'@talend/utils': minor | ||
--- | ||
|
||
TDOPS-5386 - remove phone validation as not in use |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,67 +1,40 @@ | ||
import { validFirstName, validLastName, validEmail, validPhone } from './methods'; | ||
import { | ||
validNames, | ||
invalidNames, | ||
validEmails, | ||
invalidEmails, | ||
validPhones, | ||
invalidPhones, | ||
} from './testValues'; | ||
import { validFirstName, validLastName, validEmail } from './methods'; | ||
import { validNames, invalidNames, validEmails, invalidEmails } from './testValues'; | ||
|
||
describe('methods', () => { | ||
describe('validFirstName', () => { | ||
// Test valid values | ||
test.each(validNames)( | ||
'"%s" should be an acceptable first name', | ||
(value: string) => expect(validFirstName(value)).toBe(true), | ||
test.each(validNames)('"%s" should be an acceptable first name', (value: string) => | ||
expect(validFirstName(value)).toBe(true), | ||
); | ||
|
||
// Test invalid values | ||
test.each(invalidNames)( | ||
'"%s" should not be an acceptable first name', | ||
(value: string) => expect(validFirstName(value)).toBe(false), | ||
test.each(invalidNames)('"%s" should not be an acceptable first name', (value: string) => | ||
expect(validFirstName(value)).toBe(false), | ||
); | ||
}); | ||
|
||
describe('validLastName', () => { | ||
// Test valid values | ||
test.each(validNames)( | ||
'"%s" should be an acceptable last name', | ||
(value: string) => expect(validLastName(value)).toBe(true), | ||
test.each(validNames)('"%s" should be an acceptable last name', (value: string) => | ||
expect(validLastName(value)).toBe(true), | ||
); | ||
|
||
// Test invalid values | ||
test.each(invalidNames)( | ||
'"%s" should not be an acceptable last name', | ||
(value: string) => expect(validLastName(value)).toBe(false), | ||
test.each(invalidNames)('"%s" should not be an acceptable last name', (value: string) => | ||
expect(validLastName(value)).toBe(false), | ||
); | ||
}); | ||
|
||
describe('validEmail', () => { | ||
// Test valid values | ||
test.each(validEmails)( | ||
'"%s" should be an acceptable email', | ||
(value: string) => expect(validEmail(value)).toBe(true), | ||
test.each(validEmails)('"%s" should be an acceptable email', (value: string) => | ||
expect(validEmail(value)).toBe(true), | ||
); | ||
|
||
// Test invalid values | ||
test.each(invalidEmails)( | ||
'"%s" should not be an acceptable email', | ||
(value: string) => expect(validEmail(value)).toBe(false), | ||
); | ||
}); | ||
|
||
describe('validPhone', () => { | ||
// Test valid values | ||
test.each(validPhones)( | ||
'"%s" should be an acceptable phone', | ||
(value: string) => expect(validPhone(value)).toBe(true), | ||
); | ||
|
||
// Test invalid values | ||
test.each(invalidPhones)( | ||
'"%s" should not be an acceptable phone', | ||
(value: string) => expect(validPhone(value)).toBe(false), | ||
test.each(invalidEmails)('"%s" should not be an acceptable email', (value: string) => | ||
expect(validEmail(value)).toBe(false), | ||
); | ||
}); | ||
}); |
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,13 +1,6 @@ | ||
/* eslint-disable no-useless-escape */ | ||
|
||
export const PHONE = | ||
/^((?:\+[\d().-]*\d[\d().-]*|[0-9A-F*#().-]*[0-9A-F*#][0-9A-F*#().-]*(?:;[a-z\d-]+(?:=(?:[a-z\d\[\]\/:&+$_!~*'().-]|%[\dA-F]{2})+)?)*;phone-context=(?:\+[\d().-]*\d[\d().-]*|(?:[a-z0-9]\.|[a-z0-9][a-z0-9-]*[a-z0-9]\.)*(?:[a-z]|[a-z][a-z0-9-]*[a-z0-9])))(?:;[a-z\d-]+(?:=(?:[a-z\d\[\]\/:&+$_!~*'().-]|%[\dA-F]{2})+)?)*(?:,(?:\+[\d().-]*\d[\d().-]*|[0-9A-F*#().-]*[0-9A-F*#][0-9A-F*#().-]*(?:;[a-z\d-]+(?:=(?:[a-z\d\[\]\/:&+$_!~*'().-]|%[\dA-F]{2})+)?)*;?)*)*)$/; | ||
|
||
export const EMAIL = | ||
/^[a-z0-9!#$%&'*+/=?^_`{|}~-]+(?:\.[a-z0-9!#$%&'*+/=?^_`{|}~-]+)*@(?:[a-z0-9](?:[a-z0-9-]*[a-z0-9])?\.)*[a-z0-9](?:[a-z0-9-]*[a-z0-9])?$/i; | ||
|
||
export const NAME = /^[^\~!@#$%^&*()|+=?;:",<>\{\}\[\]\\\/¤€¨£°§]*$/i; | ||
|
||
export const DOMAIN = /^[^\~!#$%^&*()|+=?;:",<>\{\}\[\]\\\/¤€¨£°§]*$/i; | ||
|
||
/* eslint-enable no-useless-escape */ |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -46,14 +46,3 @@ export const validEmails: Array<string> = [ | |
]; | ||
|
||
export const invalidEmails: Array<string> = ['john', 'john@', 'john @', 'john\\@re']; | ||
|
||
// Phones | ||
export const validPhones: Array<string> = ['+33102030405']; | ||
|
||
export const invalidPhones: Array<string> = [ | ||
'john', | ||
'john@', | ||
'john @', | ||
'[email protected]', | ||
'Fred', | ||
]; |