Skip to content

Commit

Permalink
Ajustando validacao do estado de SP
Browse files Browse the repository at this point in the history
  • Loading branch information
dilowagner committed May 11, 2023
1 parent b634884 commit 651a194
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 1 deletion.
14 changes: 14 additions & 0 deletions validator_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1747,6 +1747,20 @@ func TestValidatorSPValid(t *testing.T) {
assert.True(t, result)
}

func TestValidatorSPValidWithMod10(t *testing.T) {

validator := NewIEValidator()

validator.IE = "330.062.780.110" // Valido
validator.UF = validators.SP

result, err := validator.Validate()
if err != nil {
t.Error("Erro na validacao do estado de São Paulo")
}
assert.True(t, result)
}

func TestValidatorSPValidWithPLetter(t *testing.T) {

validator := NewIEValidator()
Expand Down
2 changes: 1 addition & 1 deletion validators/sp.go
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ func (v SaoPaulo) IsValid(insc string) bool {
weights = []int{3, 2, 10, 9, 8, 7, 6, 5, 4, 3, 2}
total = rule.CalculateTotal(firstBase+firstDigit+secondBase, 11, weights)
mod = rule.CalculateMod(total, 11)
secondDigit := strconv.Itoa(mod)
secondDigit := strconv.Itoa(mod % 10)

return insc == firstBase+firstDigit+secondBase+secondDigit
}

0 comments on commit 651a194

Please sign in to comment.