Skip to content

Commit

Permalink
add Certidao documentType to validation handler
Browse files Browse the repository at this point in the history
  • Loading branch information
flavioltonon committed Jul 11, 2019
1 parent f91bfaf commit baceb1f
Showing 1 changed file with 15 additions and 7 deletions.
22 changes: 15 additions & 7 deletions handler_validation.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,13 @@ import (
type documentType string

const (
CNPJ documentType = "cnpj"
CPF documentType = "cpf"
MOBILE documentType = "mobile"
PIS documentType = "pis"
SUS documentType = "sus"
TITULOELEITORAL documentType = "tituloEleitoral"
CNPJ documentType = "cnpj"
CPF documentType = "cpf"
MOBILE documentType = "mobile"
PIS documentType = "pis"
SUS documentType = "sus"
TITULO_ELEITORAL documentType = "tituloEleitoral"
CERTIDAO documentType = "certidao"
)

func Validate(t documentType, number string, mask bool) (string, error) {
Expand Down Expand Up @@ -52,13 +53,20 @@ func Validate(t documentType, number string, mask bool) (string, error) {
}
return sus.Number(mask), err

case TITULOELEITORAL:
case TITULO_ELEITORAL:
titulo, err := ParseTituloEleitoral(number)
if err != nil {
return "", err
}
return titulo.Number(mask), err

case CERTIDAO:
certidao, err := ParseCertidao(number)
if err != nil {
return "", err
}
return certidao.Number(mask), err

default:
return "", fmt.Errorf("%s is not a valid document type", t)
}
Expand Down

0 comments on commit baceb1f

Please sign in to comment.