Documentation
¶
Overview ¶
common.go - Common transformation functions
date.go - Date/time transformation functions
number.go - Number transformation functions
phone.go - Phone number normalization for multiple countries
string.go - String transformation functions
Index ¶
- func Chain(transformers ...builders.Transformer) builders.Transformer
- func Clamp(min, max float64) builders.Transformer
- func Conditional(condition func(interface{}) bool, transformer builders.Transformer) builders.Transformer
- func DateFormat(fromFormat, toFormat string) builders.Transformer
- func Default(defaultValue interface{}) builders.Transformer
- func EndOfDay() builders.Transformer
- func FormatPhone(country string) builders.Transformer
- func FromPercentage() builders.Transformer
- func Lowercase() builders.Transformer
- func NormalizePhone(defaultCountry string) builders.Transformer
- func NormalizePhoneWithCountry(country string) builders.Transformer
- func NormalizeWhitespace() builders.Transformer
- func PadLeft(minLength int, padChar rune) builders.Transformer
- func ParseDate(format string) builders.Transformer
- func Percentage() builders.Transformer
- func RemoveCurrencySymbols() builders.Transformer
- func RemoveNonAlphanumeric() builders.Transformer
- func RemoveSpaces() builders.Transformer
- func Replace(old, new string) builders.Transformer
- func Round(decimals int) builders.Transformer
- func StartOfDay() builders.Transformer
- func TitleCase() builders.Transformer
- func ToBoolean() builders.Transformer
- func ToFloat64() builders.Transformer
- func ToISO8601() builders.Transformer
- func ToInt() builders.Transformer
- func ToString() builders.Transformer
- func ToTimezone(location string) builders.Transformer
- func Trim() builders.Transformer
- func Truncate(maxLength int) builders.Transformer
- func Uppercase() builders.Transformer
- type PhoneFormat
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Chain ¶
func Chain(transformers ...builders.Transformer) builders.Transformer
Chain allows chaining multiple transformers.
func Conditional ¶
func Conditional(condition func(interface{}) bool, transformer builders.Transformer) builders.Transformer
Conditional applies a transformer only if a condition is met.
func DateFormat ¶
func DateFormat(fromFormat, toFormat string) builders.Transformer
DateFormat converts between date formats.
func Default ¶
func Default(defaultValue interface{}) builders.Transformer
Default returns a default value if the input is nil or empty.
func FormatPhone ¶
func FormatPhone(country string) builders.Transformer
FormatPhone formats a normalized phone for display.
func FromPercentage ¶
func FromPercentage() builders.Transformer
FromPercentage converts percentage to decimal (15 -> 0.15).
func NormalizePhone ¶
func NormalizePhone(defaultCountry string) builders.Transformer
NormalizePhone creates a transformer for phone normalization.
func NormalizePhoneWithCountry ¶
func NormalizePhoneWithCountry(country string) builders.Transformer
NormalizePhoneWithCountry normalizes with explicit country.
func NormalizeWhitespace ¶
func NormalizeWhitespace() builders.Transformer
NormalizeWhitespace converts multiple whitespace to single space.
func PadLeft ¶
func PadLeft(minLength int, padChar rune) builders.Transformer
PadLeft pads string on the left to reach minLength.
func ParseDate ¶
func ParseDate(format string) builders.Transformer
ParseDate parses a date string with the given format.
func Percentage ¶
func Percentage() builders.Transformer
Percentage converts a decimal to percentage (0.15 -> 15).
func RemoveCurrencySymbols ¶
func RemoveCurrencySymbols() builders.Transformer
RemoveCurrencySymbols removes common currency symbols.
func RemoveNonAlphanumeric ¶
func RemoveNonAlphanumeric() builders.Transformer
RemoveNonAlphanumeric removes all non-alphanumeric characters.
func RemoveSpaces ¶
func RemoveSpaces() builders.Transformer
RemoveSpaces removes all spaces from string.
func Replace ¶
func Replace(old, new string) builders.Transformer
Replace replaces all occurrences of old with new.
func Round ¶
func Round(decimals int) builders.Transformer
Round rounds a number to specified decimal places.
func ToISO8601 ¶
func ToISO8601() builders.Transformer
ToISO8601 converts a time to ISO8601 string format.
func ToTimezone ¶
func ToTimezone(location string) builders.Transformer
ToTimezone converts time to specified timezone.
func Truncate ¶
func Truncate(maxLength int) builders.Transformer
Truncate truncates string to max length.
Types ¶
type PhoneFormat ¶
type PhoneFormat struct {
CountryCode string
CountryPrefix string
Formats []string // Possible input formats (regex)
NormalizedLen int // Expected length after normalization (excluding country code)
OutputFormat string // How to format the normalized number
}
PhoneFormat defines the format for a country's phone numbers.