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

     1  package santander
     2  
     3  import (
     4  	"fmt"
     5  
     6  	"github.com/mundipagg/boleto-api/models"
     7  	"github.com/mundipagg/boleto-api/validations"
     8  )
     9  
    10  func santanderValidateAgreementNumber(b interface{}) error {
    11  	switch t := b.(type) {
    12  	case *models.BoletoRequest:
    13  		if t.Agreement.AgreementNumber == 0 {
    14  			return models.NewErrorResponse("MP400", fmt.Sprintf("O código do convênio deve ser preenchido"))
    15  		}
    16  		return nil
    17  	default:
    18  		return validations.InvalidType(t)
    19  	}
    20  }
    21  
    22  func satanderBoletoTypeValidate(b interface{}) error {
    23  	bt := santanderBoletoTypes()
    24  
    25  	switch t := b.(type) {
    26  
    27  	case *models.BoletoRequest:
    28  		if len(t.Title.BoletoType) > 0 && bt[t.Title.BoletoType] == "" {
    29  			return models.NewErrorResponse("MP400", "espécie de boleto informada não existente")
    30  		}
    31  		return nil
    32  	default:
    33  		return validations.InvalidType(t)
    34  	}
    35  }