github.com/mundipagg/boleto-api@v0.0.0-20230620145841-3f9ec742599f/citibank/validations.go (about) 1 package citibank 2 3 import ( 4 "fmt" 5 6 "github.com/mundipagg/boleto-api/models" 7 "github.com/mundipagg/boleto-api/validations" 8 ) 9 10 func citiValidateAgency(b interface{}) error { 11 switch t := b.(type) { 12 case *models.BoletoRequest: 13 err := t.Agreement.IsAgencyValid() 14 if err != nil { 15 return models.NewErrorResponse("MP400", err.Error()) 16 } 17 return nil 18 default: 19 return validations.InvalidType(t) 20 } 21 } 22 23 func citiValidateAccount(b interface{}) error { 24 switch t := b.(type) { 25 case *models.BoletoRequest: 26 if len(t.Agreement.Account) != 10 { 27 return models.NewErrorResponse("MP400", fmt.Sprintf("A conta junto com o dígito devem conter somente 10 digítos.")) 28 } 29 return nil 30 default: 31 return validations.InvalidType(t) 32 } 33 } 34 35 func citiValidateWallet(b interface{}) error { 36 switch t := b.(type) { 37 case *models.BoletoRequest: 38 if t.Agreement.Wallet < 100 || t.Agreement.Wallet > 999 { 39 return models.NewErrorResponse("MP400", fmt.Sprintf("A wallet deve conter somente 3 digítos.")) 40 } 41 return nil 42 default: 43 return validations.InvalidType(t) 44 } 45 }