Created
March 14, 2018 14:05
-
-
Save hamiltongabriel/af1d889c25a356c721c47a2f2409c781 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
| ^([0-2][0-3])[0-5][0-9]+$ |
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
^([0-2][0-3]):[0-5][0-9]+$