move args int validation to their creation

This commit is contained in:
Fabio Bozzo
2024-12-02 12:24:06 +01:00
parent 105323b989
commit 56eab758ed
3 changed files with 71 additions and 5 deletions

View File

@@ -16,6 +16,7 @@ import (
"github.com/ipld/go-ipld-prime/node/basicnode"
"github.com/ipld/go-ipld-prime/printer"
"github.com/ucan-wg/go-ucan/pkg/policy/limits"
"github.com/ucan-wg/go-ucan/pkg/policy/literal"
)
@@ -62,6 +63,10 @@ func (a *Args) Add(key string, val any) error {
return err
}
if err := limits.ValidateIntegerBoundsIPLD(node); err != nil {
return fmt.Errorf("value for key %q: %w", key, err)
}
a.Values[key] = node
a.Keys = append(a.Keys, key)