identity

package
v1.5.9 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 22, 2026 License: Apache-2.0 Imports: 6 Imported by: 0

Documentation

Overview

Package identity normalizes and validates user-facing identifiers and names (emails, usernames, org, team, project and token names) so lookalike or invisible-character input cannot forge or duplicate an identity.

Index

Constants

This section is empty.

Variables

View Source
var (
	MaxNameRunes  = 100
	MaxNameBytes  = 400
	MaxEmailBytes = 254
)

Default caps, exported vars so a deployment can tune them at boot.

View Source
var ErrInvalid = errors.New("invalid text")

ErrInvalid wraps every validation failure.

Functions

func Normalize

func Normalize(s string) string

Normalize returns s in NFKC with surrounding space trimmed, so composed, decomposed and compatibility forms of one string compare equal.

func NormalizeEmail

func NormalizeEmail(s string) string

NormalizeEmail is the canonical form used to store and look up an email or username: NFKC, trimmed, lowercased.

func Sanitize

func Sanitize(s string) string

Sanitize replaces characters that could spoof or break a log or audit view with U+FFFD, for values that are shown but cannot be rejected.

func ValidateEmail

func ValidateEmail(s string) (string, error)

ValidateEmail normalizes s and rejects control, format, space and over-long input. A value without "@" passes, legacy bare usernames exist.

func ValidateName

func ValidateName(label, s string) (string, error)

ValidateName normalizes a display name to NFC and rejects control, bidi, zero-width and invisible-filler characters and over-long input. ZWNJ and ZWJ stay allowed: scripts such as Persian need them.

Types

This section is empty.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL