diff --git a/pkg/core/object/fmt.go b/pkg/core/object/fmt.go index 40e07e74..b0741e15 100644 --- a/pkg/core/object/fmt.go +++ b/pkg/core/object/fmt.go @@ -231,7 +231,10 @@ func expirationEpochAttribute(obj *Object) (uint64, error) { return 0, errNoExpirationEpoch } -var errDuplAttr = errors.New("duplication of attributes detected") +var ( + errDuplAttr = errors.New("duplication of attributes detected") + errEmptyAttrVal = errors.New("empty attribute value") +) func (v *FormatValidator) checkAttributes(obj *Object) error { as := obj.Attributes() @@ -245,6 +248,10 @@ func (v *FormatValidator) checkAttributes(obj *Object) error { return errDuplAttr } + if a.Value() == "" { + return errEmptyAttrVal + } + mUnique[key] = struct{}{} } diff --git a/pkg/core/object/fmt_test.go b/pkg/core/object/fmt_test.go index c23ee28b..f186182b 100644 --- a/pkg/core/object/fmt_test.go +++ b/pkg/core/object/fmt_test.go @@ -222,7 +222,7 @@ func TestFormatValidator_Validate(t *testing.T) { t.Run("attributes", func(t *testing.T) { t.Run("duplication", func(t *testing.T) { - obj := blankValidObject(t, ownerKey) + obj := blankValidObject(t, &ownerKey.PrivateKey) a1 := object.NewAttribute() a1.SetKey("key1") @@ -242,5 +242,17 @@ func TestFormatValidator_Validate(t *testing.T) { err = v.checkAttributes(obj.Object()) require.Equal(t, errDuplAttr, err) }) + + t.Run("empty value", func(t *testing.T) { + obj := blankValidObject(t, &ownerKey.PrivateKey) + + a := object.NewAttribute() + a.SetKey("key") + + obj.SetAttributes(a) + + err := v.checkAttributes(obj.Object()) + require.Equal(t, errEmptyAttrVal, err) + }) }) }