github.com/mundipagg/boleto-api@v0.0.0-20230620145841-3f9ec742599f/pefisa/validations.go (about)

     1  package pefisa
     2  
     3  import (
     4  	"github.com/mundipagg/boleto-api/models"
     5  	"github.com/mundipagg/boleto-api/validations"
     6  )
     7  
     8  func pefisaBoletoTypeValidate(b interface{}) error {
     9  	bt := pefisaBoletoTypes()
    10  
    11  	switch t := b.(type) {
    12  
    13  	case *models.BoletoRequest:
    14  		if len(t.Title.BoletoType) > 0 && bt[t.Title.BoletoType] == "" {
    15  			return models.NewErrorResponse("MP400", "espécie de boleto informada não existente")
    16  		}
    17  		return nil
    18  	default:
    19  		return validations.InvalidType(t)
    20  	}
    21  }