Skip to content

Commit

Permalink
feat: Enforce Rule.ObjectID not to be empty (closes #397)
Browse files Browse the repository at this point in the history
  • Loading branch information
aseure committed Apr 11, 2018
1 parent 5ff7df4 commit 22e2592
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 0 deletions.
4 changes: 4 additions & 0 deletions algoliasearch/check_rule.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,10 @@ func checkRules(rules []Rule) error {
for _, rule := range rules {
consequenceParams := rule.Consequence.Params

if rule.ObjectID == "" {
return emptyField("Rule.ObjectID")
}

// The elements of the RuleConsequence's Params map are first checked
// as query parameters (as any regular query parameters is considered
// valid) at the exception of the "query" field, if any, which is
Expand Down
4 changes: 4 additions & 0 deletions algoliasearch/utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,10 @@ func invalidType(p, t string) error {
return fmt.Errorf("`%s` should be of type `%s`", p, t)
}

func emptyField(fieldName string) error {
return fmt.Errorf("Field `%s` cannot be empty", fieldName)
}

func duplicateMap(m Map) Map {
copy := make(Map)

Expand Down

0 comments on commit 22e2592

Please sign in to comment.