Documentation
¶
Index ¶
- Variables
- func FormatDate(date string) (string, error)
- func FormatToCentimeters(input string) (int, error)
- func FormatToMilliseconds(input string) (int, error)
- func IsBefore(date1 string, date2 string) error
- func IsDate(date string) error
- func IsDuration(s string) error
- func IsEmail(email string) error
- func IsEmpty(bodyPart string) error
- func IsFuture(date string) error
- func IsSex(sex string) error
- func NormalizeResult(raw string, unit string) (int, error)
Constants ¶
This section is empty.
Variables ¶
var ( InvalidSexLengthError = errors.New("Sex should be one character only") InvalidSexValue = errors.New("Sex can only be <m|f|d>") InvalidEmailAddressFormatError = errors.New("Email address format is invalid") EmailAddressContainsNameError = errors.New("Email address should not contain the name") EmailAddressInvalidTldError = errors.New("Email address TLD is invalid") DateFormatInvalidError = errors.New("Date format is invalid") DateInFutureError = errors.New("Date is in the future") EmptyStringError = errors.New("Empty String") )
Functions ¶
func FormatDate ¶
FormatDate converts a date string from RFC3339 (e.g., "2003-01-17T00:00:00Z") to the format "YYYY-MM-DD".
func FormatToCentimeters ¶
FormatToCentimeters converts inputs like "2.40 m" or "800 m" into centimeters as string.
func FormatToMilliseconds ¶
FormatToMilliseconds converts a time string like "03:25" or "1:02:30" into milliseconds.
func IsDate ¶
IsDate checks if the given date is in the required format (YYYY-MM-DD). Throws: DateFormatInvalidError
func IsDuration ¶
IsDuration checks whether s is a valid duration in the format S, SS, M:SS or MM:SS. Seconds must be 0-59; any non-negative number can be used for minutes, but only 1 or 2 digits in the string.
func IsEmail ¶
IsEmail validates the email address using the mail.ParseAddress function and additionally checks if it has a valid TLD to block local addresses
Types ¶
This section is empty.