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

     1  package validations
     2  
     3  import (
     4  	"github.com/mundipagg/boleto-api/models"
     5  )
     6  
     7  func ValidateInterest(b interface{}) error {
     8  	switch t := b.(type) {
     9  	case *models.BoletoRequest:
    10  		if t.Title.Fees.HasInterest() {
    11  			if err := t.Title.Fees.Interest.Validate(); err != nil {
    12  				return err
    13  			}
    14  		}
    15  		return nil
    16  	default:
    17  		return InvalidType(t)
    18  	}
    19  }
    20  
    21  func ValidateFine(b interface{}) error {
    22  	switch t := b.(type) {
    23  	case *models.BoletoRequest:
    24  		if t.Title.Fees.HasFine() {
    25  			if err := t.Title.Fees.Fine.Validate(); err != nil {
    26  				return err
    27  			}
    28  		}
    29  		return nil
    30  	default:
    31  		return InvalidType(t)
    32  	}
    33  }