package domain

import (
	"fmt"
	"strings"
)

func NormalizeCurrency(currency string) string {
	return strings.ToUpper(strings.TrimSpace(currency))
}

func ValidateCurrency(currency string) error {
	if len(currency) != 3 {
		return fmt.Errorf("%w: currency must be an ISO-4217 code", ErrValidation)
	}
	for _, r := range currency {
		if r < 'A' || r > 'Z' {
			return fmt.Errorf("%w: currency must contain only letters", ErrValidation)
		}
	}
	return nil
}

func ValidateAmount(amountCents int64) error {
	if amountCents <= 0 {
		return fmt.Errorf("%w: amount_cents must be greater than zero", ErrValidation)
	}
	return nil
}
