common/identity/identity.go
2025-01-12 08:17:29 +00:00

25 lines
498 B
Go

package identity
import (
"fmt"
"git.grassecon.net/grassrootseconomics/common/phone"
)
// CheckRecipient validates the recipient format based on the criteria
func CheckRecipient(recipient string) (string, error) {
if phone.IsValidPhoneNumber(recipient) {
return "phone number", nil
}
if IsValidAddress(recipient) {
return "address", nil
}
if IsValidAlias(recipient) {
return "alias", nil
}
return "", fmt.Errorf("invalid recipient: must be a phone number, address or alias")
}