Skip to content

Instantly share code, notes, and snippets.

@hamiltongabriel
Created March 14, 2018 14:05
Show Gist options
  • Save hamiltongabriel/af1d889c25a356c721c47a2f2409c781 to your computer and use it in GitHub Desktop.
Save hamiltongabriel/af1d889c25a356c721c47a2f2409c781 to your computer and use it in GitHub Desktop.
^([0-2][0-3])[0-5][0-9]+$
@hamiltongabriel
Copy link
Author

^([0-2][0-3]):[0-5][0-9]+$

@hamiltongabriel
Copy link
Author

hamiltongabriel commented Mar 14, 2018

export function pis (PIS) {
if (PIS === '' || PIS === null) {
return false
}
if (String(PIS).match(/(\d)\1{9}/g)) {
return false
}
PIS = String(PIS).replace(/\D+/g, '')
const pesos = [3, 2, 9, 8, 7, 6, 5, 4, 3, 2]
let soma = 0
for (let i = 0; i < 10; i++) {
soma += pesos[i] * Number(PIS.charAt(i))
}
soma = soma % 11
soma = 11 - soma
soma = soma > 9 ? 0 : soma

return String(soma) === PIS.charAt(10)
}

export function hora (HORA) {
if (HORA == '' || HORA == null) {
return false
}
if (String(HORA).match(/^([0-2][0-3])[0-5][0-9]+$/g)) {
return true
}else {
return false
}
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment