-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added base64, ean, mac, pan, passport, sin and tin validation functions.
- Loading branch information
Showing
20 changed files
with
788 additions
and
149 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
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 |
---|---|---|
@@ -0,0 +1,33 @@ | ||
import { isValid_Base64 } from '../base64'; | ||
|
||
describe('Base64 Validation', () => { | ||
it('should return true for a valid Base64 string', () => { | ||
const validBase64 = 'U29mdHdhcmUgRW5naW5lZXJpbmc='; | ||
expect(isValid_Base64(validBase64)).toBe(true); | ||
}); | ||
|
||
it('should return true for a valid Base64 string with padding', () => { | ||
const validBase64WithPadding = 'U29mdHdhcmU='; | ||
expect(isValid_Base64(validBase64WithPadding)).toBe(true); | ||
}); | ||
|
||
it('should return false for an invalid Base64 string with invalid characters', () => { | ||
const invalidBase64 = 'U29mdHdhcmU$'; | ||
expect(isValid_Base64(invalidBase64)).toBe(false); | ||
}); | ||
|
||
it('should return false for a string with incorrect Base64 padding', () => { | ||
const incorrectPadding = 'U29mdHdhcmU=='; | ||
expect(isValid_Base64(incorrectPadding)).toBe(false); | ||
}); | ||
|
||
it('should return true for an empty string (considered valid Base64)', () => { | ||
const emptyString = ''; | ||
expect(isValid_Base64(emptyString)).toBe(true); | ||
}); | ||
|
||
it('should return false for a non-Base64 string', () => { | ||
const nonBase64 = 'Hello, World!'; | ||
expect(isValid_Base64(nonBase64)).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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
import { isValid_EAN_UPC } from '../ean-uac-code'; | ||
|
||
describe('EAN/UPC Code Validation', () => { | ||
it('should return true for a valid 8-digit UPC code', () => { | ||
const validUPC8 = '12345678'; | ||
expect(isValid_EAN_UPC(validUPC8)).toBe(true); | ||
}); | ||
|
||
it('should return true for a valid 12-digit UPC code', () => { | ||
const validUPC12 = '123456789012'; | ||
expect(isValid_EAN_UPC(validUPC12)).toBe(true); | ||
}); | ||
|
||
it('should return true for a valid 13-digit EAN code', () => { | ||
const validEAN13 = '1234567890123'; | ||
expect(isValid_EAN_UPC(validEAN13)).toBe(true); | ||
}); | ||
|
||
it('should return false for a code with less than 8 digits', () => { | ||
const shortCode = '1234567'; | ||
expect(isValid_EAN_UPC(shortCode)).toBe(false); | ||
}); | ||
|
||
it('should return false for a code with more than 13 digits', () => { | ||
const longCode = '12345678901234'; | ||
expect(isValid_EAN_UPC(longCode)).toBe(false); | ||
}); | ||
|
||
it('should return false for a code with non-numeric characters', () => { | ||
const nonNumericCode = '12345A789012'; | ||
expect(isValid_EAN_UPC(nonNumericCode)).toBe(false); | ||
}); | ||
|
||
it('should return false for an empty string', () => { | ||
const emptyString = ''; | ||
expect(isValid_EAN_UPC(emptyString)).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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
import { isValid_MAC_Address } from '../mac-address'; | ||
|
||
describe('MAC Address Validation', () => { | ||
it('should return true for a valid MAC address', () => { | ||
const validMAC = '01:23:45:67:89:AB'; | ||
expect(isValid_MAC_Address(validMAC)).toBe(true); | ||
}); | ||
|
||
it('should return true for a valid MAC address with lowercase letters', () => { | ||
const validMACLower = '01:23:45:67:89:ab'; | ||
expect(isValid_MAC_Address(validMACLower)).toBe(true); | ||
}); | ||
|
||
it('should return false for a MAC address with invalid characters', () => { | ||
const invalidMACChars = '01:23:45:67:89:ZZ'; | ||
expect(isValid_MAC_Address(invalidMACChars)).toBe(false); | ||
}); | ||
|
||
it('should return false for a MAC address with incorrect length', () => { | ||
const shortMAC = '01:23:45:67:89'; | ||
expect(isValid_MAC_Address(shortMAC)).toBe(false); | ||
}); | ||
|
||
it('should return false for a MAC address with incorrect delimiter', () => { | ||
const invalidDelimiterMAC = '01-23-45-67-89-AB'; | ||
expect(isValid_MAC_Address(invalidDelimiterMAC)).toBe(false); | ||
}); | ||
|
||
it('should return false for an empty string', () => { | ||
const emptyString = ''; | ||
expect(isValid_MAC_Address(emptyString)).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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
import { isValid_PAN } from '../pan'; | ||
|
||
describe('PAN Validation', () => { | ||
it('should return true for a valid PAN', () => { | ||
const validPAN = 'ABCDE1234F'; | ||
expect(isValid_PAN(validPAN)).toBe(true); | ||
}); | ||
|
||
it('should return false for a PAN with incorrect letter count', () => { | ||
const invalidPANLetters = 'ABCD1234F'; | ||
expect(isValid_PAN(invalidPANLetters)).toBe(false); | ||
}); | ||
|
||
it('should return false for a PAN with incorrect digit count', () => { | ||
const invalidPANDigits = 'ABCDE123F'; | ||
expect(isValid_PAN(invalidPANDigits)).toBe(false); | ||
}); | ||
|
||
it('should return false for a PAN with lowercase letters', () => { | ||
const invalidPANLowercase = 'abcde1234f'; | ||
expect(isValid_PAN(invalidPANLowercase)).toBe(false); | ||
}); | ||
|
||
it('should return false for a PAN with special characters', () => { | ||
const invalidPANSpecialChars = 'ABCD@1234F'; | ||
expect(isValid_PAN(invalidPANSpecialChars)).toBe(false); | ||
}); | ||
|
||
it('should return false for an empty string', () => { | ||
const emptyString = ''; | ||
expect(isValid_PAN(emptyString)).toBe(false); | ||
}); | ||
}); |
Oops, something went wrong.