(str string)
| 38 | } |
| 39 | |
| 40 | func StatusFromString(str string) (Status, error) { |
| 41 | cleaned := strings.ToLower(strings.TrimSpace(str)) |
| 42 | |
| 43 | switch cleaned { |
| 44 | case "open": |
| 45 | return OpenStatus, nil |
| 46 | case "closed": |
| 47 | return ClosedStatus, nil |
| 48 | default: |
| 49 | return 0, fmt.Errorf("unknown status") |
| 50 | } |
| 51 | } |
| 52 | |
| 53 | func (s Status) Validate() error { |
| 54 | if s != OpenStatus && s != ClosedStatus { |
no test coverage detected