(candidateName string)
| 658 | } |
| 659 | |
| 660 | func validateName(candidateName string) error { |
| 661 | candidateName = strings.TrimSpace(candidateName) |
| 662 | if candidateName == "" { |
| 663 | return errors.New("A unique name is required") |
| 664 | } |
| 665 | |
| 666 | if existingMonitors.HasMonitorByName(candidateName) { |
| 667 | return errors.New("Sorry, you already have a monitor with this name. A unique name is required") |
| 668 | } |
| 669 | |
| 670 | if inputLen := len(candidateName); inputLen > maxNameLen { |
| 671 | return errors.New(fmt.Sprintf("Sorry, name is too long: %d of maximum %d chars", inputLen, maxNameLen)) |
| 672 | } |
| 673 | |
| 674 | return nil |
| 675 | } |
| 676 | |
| 677 | type item struct { |
| 678 | title, desc string |
no test coverage detected