ValidateAbsolutePaths ensures every populated entry in a list is absolute.
(prefix string, field string, values []string)
| 105 | |
| 106 | // ValidateAbsolutePaths ensures every populated entry in a list is absolute. |
| 107 | func validateAbsolutePathsInternal(prefix string, field string, values []string) error { |
| 108 | for _, value := range values { |
| 109 | trimmed := strings.TrimSpace(value) |
| 110 | if trimmed == "" { |
| 111 | continue |
| 112 | } |
| 113 | if !filepath.IsAbs(trimmed) { |
| 114 | return prefixedError(prefix, field+" entries must be absolute paths") |
| 115 | } |
| 116 | } |
| 117 | return nil |
| 118 | } |
| 119 | |
| 120 | // TrimStringSlice trims all entries while preserving order and cardinality. |
| 121 | func trimStringSliceInternal(values []string) []string { |