Ajuste na regex da conta bancária para aceitar dígito X

This commit is contained in:
Leandro Costa 2022-02-07 16:56:25 -03:00
parent d09e0e2728
commit b7a18af8a3
2 changed files with 6 additions and 2 deletions

View file

@ -68,7 +68,7 @@ function formatarCpfCnpj(txt) {
// Entrada: 12345 Saída: 1234-5
function formatarContaBancaria(txt) {
const soNumeros = `${txt}`.replace(/[^\d]/g, '')
const soNumeros = `${txt}`.replace(/[^\dxX]/g, '')
if (!soNumeros) return soNumeros;
let conta = '';

View file

@ -22,7 +22,11 @@ const testes = {
},
'contabancaria': {
'fnName': "formatarContaBancaria",
'valores': [['1234-5', '1234-5']]
'valores': [
['12345', '1234-5'],
['12345x', '12345-x'],
['12345X', '12345-X']
]
},
'telefone': {
'fnName': 'formatarTelefone',