Don't import invalid .nsp files

This commit is contained in:
Deluan
2021-10-22 15:14:41 -04:00
committed by Deluan Quintão
parent 6a550dab77
commit 2c860edeb5
4 changed files with 9 additions and 4 deletions
+3
View File
@@ -3,6 +3,7 @@ package criteria
import (
"encoding/json"
"errors"
"strings"
"github.com/Masterminds/squirrel"
@@ -71,6 +72,8 @@ func (c *Criteria) UnmarshalJSON(data []byte) error {
c.Expression = Any(aux.Any)
} else if len(aux.All) > 0 {
c.Expression = All(aux.All)
} else {
return errors.New("invalid criteria json. missing rules (key 'all' or 'any')")
}
c.Sort = aux.Sort
c.Order = aux.Order