Skip to content

Commit

Permalink
add the start of Core 20 extensions support to the model assertion
Browse files Browse the repository at this point in the history
  • Loading branch information
pedronis committed Aug 23, 2019
1 parent 62c26de commit 6acd494
Show file tree
Hide file tree
Showing 7 changed files with 757 additions and 113 deletions.
8 changes: 6 additions & 2 deletions asserts/header_checks.go
Original file line number Diff line number Diff line change
Expand Up @@ -62,18 +62,22 @@ func checkNotEmptyStringWhat(m map[string]interface{}, name, what string) (strin
return s, nil
}

func checkOptionalString(headers map[string]interface{}, name string) (string, error) {
func checkOptionalStringWhat(headers map[string]interface{}, name, what string) (string, error) {
value, ok := headers[name]
if !ok {
return "", nil
}
s, ok := value.(string)
if !ok {
return "", fmt.Errorf("%q header must be a string", name)
return "", fmt.Errorf("%q %s must be a string", name, what)
}
return s, nil
}

func checkOptionalString(headers map[string]interface{}, name string) (string, error) {
return checkOptionalStringWhat(headers, name, "header")
}

func checkPrimaryKey(headers map[string]interface{}, primKey string) (string, error) {
value, err := checkNotEmptyString(headers, primKey)
if err != nil {
Expand Down
Loading

0 comments on commit 6acd494

Please sign in to comment.