forked from TrueCloudLab/frostfs-node
[#58] core/object: Decouple the payload content validation method
Signed-off-by: Leonard Lyubich <leonard@nspcc.ru>
This commit is contained in:
parent
107f3097e4
commit
2abb03dbd1
2 changed files with 7 additions and 22 deletions
|
@ -25,6 +25,8 @@ func NewFormatValidator() *FormatValidator {
|
|||
|
||||
// Validate validates object format.
|
||||
//
|
||||
// Does not validate payload checksum and content.
|
||||
//
|
||||
// Returns nil error if object has valid structure.
|
||||
func (v *FormatValidator) Validate(obj *Object) error {
|
||||
if obj == nil {
|
||||
|
@ -35,10 +37,6 @@ func (v *FormatValidator) Validate(obj *Object) error {
|
|||
return errNilCID
|
||||
}
|
||||
|
||||
if err := v.validateContent(obj.GetType(), obj.GetPayload()); err != nil {
|
||||
return errors.Wrapf(err, "(%T) incorrect content", v)
|
||||
}
|
||||
|
||||
if err := v.validateSignatureKey(obj); err != nil {
|
||||
return errors.Wrapf(err, "(%T) could not validate signature key", v)
|
||||
}
|
||||
|
@ -88,7 +86,8 @@ func (v *FormatValidator) checkOwnerKey(id *owner.ID, key []byte) error {
|
|||
return nil
|
||||
}
|
||||
|
||||
func (v *FormatValidator) validateContent(t object.Type, payload []byte) error {
|
||||
// ValidateContent validates payload content according to object type.
|
||||
func (v *FormatValidator) ValidateContent(t object.Type, payload []byte) error {
|
||||
switch t {
|
||||
case object.TypeTombstone:
|
||||
if len(payload) == 0 {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue