Documentation
¶
Index ¶
- func CheckRule(rule string) (ok bool)
- func IsLowerCaseIdentifier(id string) bool
- func IsUpperCaseIdentifier(id string) bool
- func JoinHostAndPath(host string, path string) string
- func ParseURL(rawURL string) (canonical *url.URL, err error)
- func ToKebabCase(id string) string
- func ToSnakeCase(id string) string
- func Validate(rule string, value string) (ok bool)
- func ValidateHostname(hostname string) error
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func CheckRule ¶
CheckRule validates that the validation rule itself is valid.
Valid rules are:
str ^[a-zA-Z0-9]+$ bool int [0,60] float [0.0,1.0) dur (0s,24h] set Red|Green|Blue url email json
Whereas the following types are synonymous:
str, string, text, (empty) bool, boolean int, integer, long float, double, decimal, number dur, duration
func IsLowerCaseIdentifier ¶
IsLowerCaseIdentifier accepts only lowerCaseIdentifiers.
func IsUpperCaseIdentifier ¶
IsUpperCaseIdentifier accepts only UpperCaseIdentifiers.
func JoinHostAndPath ¶
JoinHostAndPath combines the path shorthand with a hostname.
func ParseURL ¶
ParseURL returns a canonical version of the parsed URL with the scheme and port filled in if omitted. This method should only be used on internal URLs because it limits the hostname to certain specifications.
func ToKebabCase ¶
ToKebabCase converts a CamelCase identifier to kebab-case. Consecutive non-letters or numbers are compressed into a single hyphen.
func ToSnakeCase ¶
ToSnakeCase converts a CamelCase identifier to snake_case. Consecutive non-letters are compressed into a single underscore.
func Validate ¶
Validate validates that the value matches the rule. The rule itself is assumed to be valid.
func ValidateHostname ¶
ValidateHostname indicates if the hostname is a valid microservice hostname. Hostnames must contain only alphanumeric characters, hyphens, underscores and dot separators.
Types ¶
This section is empty.