Merge branch 'p2pix-V2' of github.com:liftlearning/P2Pix-Front-End into p2pix-V2

This commit is contained in:
RcleydsonR
2023-02-06 14:11:05 -03:00
2 changed files with 41 additions and 0 deletions

16
src/utils/pixKeyFormat.ts Normal file
View File

@@ -0,0 +1,16 @@
export const pixFormatValidation = (pixKey: string): boolean => {
const cpf = /(^\d{3}\.?\d{3}\.?\d{3}-?\d{2}$)/g;
const cnpj = /(^\d{2}\.?\d{3}\.?\d{3}\/?\d{4}-?\d{2}$)/g;
const telefone = /(^[0-9]{2})?(\s|-)?(9?[0-9]{4})-?([0-9]{4}$)/g;
if (pixKey.match(cpf) || pixKey.match(cnpj) || pixKey.match(telefone)) {
return true;
}
return false;
};
export const postProcessKey = (pixKey: string): string => {
pixKey = pixKey.replace(/[-.()/]/g, "");
return pixKey;
};