MCPcopy
hub / github.com/harness/harness / sanitizeLabelText

Function sanitizeLabelText

types/label.go:265–287  ·  view source on GitHub ↗
(text *string, typ string)

Source from the content-addressed store, hash-verified

263}
264
265func sanitizeLabelText(text *string, typ string) error {
266 if text == nil {
267 return nil
268 }
269
270 *text = strings.TrimSpace(*text)
271
272 if len(*text) == 0 {
273 return errors.InvalidArgument("%s must be a non-empty string", typ)
274 }
275
276 if utf8.RuneCountInString(*text) > maxLabelLength {
277 return errors.InvalidArgument("%s can have at most %d characters", typ, maxLabelLength)
278 }
279
280 for _, ch := range *text {
281 if unicode.IsControl(ch) {
282 return errors.InvalidArgument("%s cannot contain control characters", typ)
283 }
284 }
285
286 return nil
287}
288
289func sanitizeDescription(description *string) {
290 if description == nil {

Callers 4

SanitizeMethod · 0.85
SanitizeMethod · 0.85
SanitizeMethod · 0.85
SanitizeMethod · 0.85

Calls 1

InvalidArgumentFunction · 0.92

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…