Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
View Source
var ValidateDirPath = func(path string) error { _, err := os.ReadDir(path) if err != nil { return err } return nil }
ValidateDirPath validates that the given string is a valid directory path.
View Source
var ValidateGreaterThanOrEqualToZero = func(v int) error { if v < 0 { return fmt.Errorf("must be greater than or equal to 0: %d", v) } return nil }
ValidateGreaterThanOrEqualToZero validates that the given integer is greater than or equal to zero.
View Source
var ValidateGreaterThanZero = func(v int) error { if v < 1 { return fmt.Errorf("must be greater than 0: %d", v) } return nil }
ValidateGreaterThanZero validates that the given integer is greater than zero.
View Source
var ValidateHost = func(host string) error { if host == "" { return errors.New("host cannot be empty") } h, portStr, err := net.SplitHostPort(host) if err == nil { port, convErr := strconv.Atoi(portStr) if convErr != nil { return fmt.Errorf("invalid port %q: %w", portStr, convErr) } if portErr := ValidatePort(port); portErr != nil { return fmt.Errorf("invalid port: %w", portErr) } host = h } if net.ParseIP(host) != nil { return nil } return ValidateHostname(host) }
View Source
var ValidatePort = func(v int) error { if v < 1000 || v > 65535 { return fmt.Errorf("must be between 1000 and 65535: %d", v) } return nil }
ValidatePort validates that the given integer is a valid port number (between 1000 and 65535).
Functions ¶
func ValidateHostname ¶ added in v1.2.0
ValidateHostname reports whether s is a syntactically valid DNS hostname. It enforces RFC 1123: dot-separated labels, each 1–63 characters of [A-Za-z0-9] with interior hyphens permitted, total length ≤ 253.
Types ¶
This section is empty.
Click to show internal directories.
Click to hide internal directories.