Documentation ¶
Index ¶
- func FindPhoneNumbers(s, country string) []string
- func Indent(s string, prefix string) string
- func IsNil(v interface{}) bool
- func Max[T constraints.Ordered](x, y T) T
- func Min[T constraints.Ordered](x, y T) T
- func ParsePhoneNumber(s, country string) string
- func PrefixOverlap(s1, s2 string) int
- func ReadTypeFromJSON(data []byte) (string, error)
- func RegisterStructValidator(fn validator.StructLevelFunc, types ...interface{})
- func RegisterValidatorAlias(alias, tags string, message ErrorMessageFunc)
- func RegisterValidatorTag(tag string, fn validator.Func, message ErrorMessageFunc)
- func ReplaceEscapedNulls(data []byte, repl []byte) []byte
- func Snakify(text string) string
- func StringSet(s []string) map[string]bool
- func StringSetKeys(m map[string]bool) []string
- func StringSliceContains(slice []string, str string, caseSensitive bool) bool
- func StringSlices(s string, indices []int) []string
- func TokenizeString(str string) []string
- func TokenizeStringByChars(str string, chars string) []string
- func TokenizeStringByUnicodeSeg(str string) []string
- func Truncate(s string, limit int) string
- func TruncateEllipsis(s string, limit int) string
- func UnmarshalAndValidate(data []byte, obj interface{}) error
- func UnmarshalAndValidateWithLimit(reader io.ReadCloser, s interface{}, limit int64) error
- func Validate(obj interface{}) error
- type Attachment
- type ErrorMessageFunc
- type Redactor
- type RichError
- type Typed
- type TypedEnvelope
- type ValidationErrors
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func FindPhoneNumbers ¶ added in v0.70.0
FindPhoneNumbers finds phone numbers anywhere in the given string
func IsNil ¶ added in v0.4.0
func IsNil(v interface{}) bool
IsNil returns whether the given object is nil or an interface to a nil
func Max ¶ added in v0.159.0
func Max[T constraints.Ordered](x, y T) T
Max returns the maximum of two values
func Min ¶ added in v0.159.0
func Min[T constraints.Ordered](x, y T) T
Min returns the minimum of two values
func ParsePhoneNumber ¶ added in v0.70.0
ParsePhoneNumber tries to parse the given string as a phone number. If successful, it returns it formatted as E164.
func PrefixOverlap ¶ added in v0.14.7
PrefixOverlap returns the number of prefix characters which s1 and s2 have in common
func ReadTypeFromJSON ¶ added in v0.22.0
ReadTypeFromJSON reads a field called `type` from the given JSON
func RegisterStructValidator ¶ added in v0.96.0
func RegisterStructValidator(fn validator.StructLevelFunc, types ...interface{})
RegisterStructValidator registers a struct level validator
func RegisterValidatorAlias ¶ added in v0.96.0
func RegisterValidatorAlias(alias, tags string, message ErrorMessageFunc)
RegisterValidatorAlias registers a tag alias
func RegisterValidatorTag ¶ added in v0.96.0
func RegisterValidatorTag(tag string, fn validator.Func, message ErrorMessageFunc)
RegisterValidatorTag registers a tag
func ReplaceEscapedNulls ¶ added in v0.126.0
replaces any `\u0000` sequences with the given replacement sequence which may be empty. A sequence such as `\\u0000` is preserved as it is an escaped slash followed by the sequence `u0000`
func Snakify ¶
Snakify turns the passed in string into a context reference. We replace all whitespace characters with _ and replace any duplicate underscores
func StringSet ¶ added in v0.78.1
StringSet converts a slice of strings to a set (a string > bool map)
func StringSetKeys ¶ added in v0.64.2
StringSetKeys returns the keys of string set in lexical order
func StringSliceContains ¶ added in v0.30.2
StringSliceContains determines whether the given slice of strings contains the given string
func StringSlices ¶ added in v0.28.3
StringSlices returns the slices of s defined by pairs of indexes in indices
func TokenizeString ¶
TokenizeString returns the words in the passed in string, split by non word characters including emojis
func TokenizeStringByChars ¶ added in v0.10.17
TokenizeStringByChars returns the words in the passed in string, split by the chars in the given string
func TokenizeStringByUnicodeSeg ¶ added in v0.66.1
TokenizeStringByUnicodeSeg tokenizes the given string using the Unicode Text Segmentation standard described at http://www.unicode.org/reports/tr29/
func Truncate ¶ added in v0.64.10
Truncate truncates the given string to ensure it's less than limit characters
func TruncateEllipsis ¶ added in v0.66.1
TruncateEllipsis truncates the given string and adds ellipsis where the input is cut
func UnmarshalAndValidate ¶ added in v0.4.0
UnmarshalAndValidate is a convenience function to unmarshal an object and validate it
func UnmarshalAndValidateWithLimit ¶ added in v0.13.1
func UnmarshalAndValidateWithLimit(reader io.ReadCloser, s interface{}, limit int64) error
UnmarshalAndValidateWithLimit unmarshals a struct with a limit on how many bytes can be read from the given reader
Types ¶
type Attachment ¶ added in v0.32.0
type Attachment string
Attachment is a media attachment on a message in the format <content-type>:<url>. Content type may be a full media type or may omit the subtype when it is unknown.
Examples:
- image/jpeg:http://s3.amazon.com/bucket/test.jpg
- image:http://s3.amazon.com/bucket/test.jpg
func (Attachment) ContentType ¶ added in v0.32.0
func (a Attachment) ContentType() string
ContentType returns the MIME type of this attachment
func (Attachment) ToParts ¶ added in v0.32.0
func (a Attachment) ToParts() (string, string)
ToParts splits an attachment string into content-type and URL
func (Attachment) URL ¶ added in v0.32.0
func (a Attachment) URL() string
URL returns the full URL of this attachment
type ErrorMessageFunc ¶ added in v0.96.0
type ErrorMessageFunc func(validator.FieldError) string
ErrorMessageFunc is the type for a function that can convert a field error to user friendly message
type Redactor ¶ added in v0.86.1
Redactor is a function which can redact the given string
func NewRedactor ¶ added in v0.86.1
NewRedactor creates a new redaction function which replaces the given values
type RichError ¶ added in v0.97.0
RichError is a common interface for error types that can provide more detail
type Typed ¶
type Typed interface {
Type() string
}
Typed is an interface of objects that are marshalled as typed envelopes
type TypedEnvelope ¶
type TypedEnvelope struct {
Type string `json:"type" validate:"required"`
}
TypedEnvelope can be mixed into envelopes that have a type field
type ValidationErrors ¶ added in v0.4.0
type ValidationErrors []error
ValidationErrors combines multiple validation errors as a single error
func (ValidationErrors) Error ¶ added in v0.4.0
func (e ValidationErrors) Error() string
Error returns a string representation of these validation errors