View middle-truncate-text.ts
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
/* | |
* Middle Truncate Text | |
* | |
* Example: middleTruncateText('123456789', 3), returns "123...789" | |
* | |
* @param {string} text - The text to be truncated | |
* @param {number} visibleSize - Number of chars on each side (default 5) | |
* @param {string} ellipsis - The string to place on truncated text (default '...') | |
*/ | |
export const middleTruncateText: ( |
View validate-cpf.ts
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
/* | |
* Validate Brazilian CPF number with Typescript | |
* | |
* @param {string} cpf - A string because can start with 0 | |
*/ | |
export const validateCpf: (cpf: string) => (boolean) = (cpf) => { | |
const _cpf = cpf.replace(/\D/g, ''); | |
if (_cpf.length < 11) { | |
return false; |