(body map[string]interface{}, property string)
| 525 | } |
| 526 | |
| 527 | func GetStringArrayProperty(body map[string]interface{}, property string) ([]string, error) { |
| 528 | if raw, exists := body[property]; !exists { |
| 529 | return nil, nil |
| 530 | } else if strings, ok := raw.([]string); ok { |
| 531 | return strings, nil |
| 532 | } else if items, ok := raw.([]interface{}); ok { |
| 533 | strings := make([]string, len(items)) |
| 534 | for i := 0; i < len(items); i++ { |
| 535 | strings[i], ok = items[i].(string) |
| 536 | if !ok { |
| 537 | return nil, base.HTTPErrorf(http.StatusBadRequest, "%s must be a string array", property) |
| 538 | } |
| 539 | } |
| 540 | return strings, nil |
| 541 | } else { |
| 542 | return nil, base.HTTPErrorf(http.StatusBadRequest, "%s must be a string array", property) |
| 543 | } |
| 544 | } |
no test coverage detected