validator not work

This commit is contained in:
mr 2024-07-19 09:36:46 +02:00
parent e838474835
commit c494dba5ab
6 changed files with 6 additions and 10 deletions

View File

@ -18,7 +18,7 @@ func (dma *DataMongoAccessor) UpdateOne(set map[string]interface{}, id string) (
}
func (dma *DataMongoAccessor) StoreOne(data utils.DBObject) (utils.DBObject, error) {
err := dma.Validate(data.(*Data))
err := utils.Validate.Struct(data)
if err != nil {
return nil, err
}

View File

@ -18,7 +18,7 @@ func (dca *DatacenterMongoAccessor) UpdateOne(set map[string]interface{}, id str
}
func (dca *DatacenterMongoAccessor) StoreOne(data utils.DBObject) (utils.DBObject, error) {
err := dca.Validate(data.(*Datacenter))
err := utils.Validate.Struct(data)
if err != nil {
return nil, err
}

View File

@ -18,7 +18,7 @@ func (pma *ProcessingMongoAccessor) UpdateOne(set map[string]interface{}, id str
}
func (pma *ProcessingMongoAccessor) StoreOne(data utils.DBObject) (utils.DBObject, error) {
err := pma.Validate(data.(*Processing))
err := utils.Validate.Struct(data)
if err != nil {
return nil, err
}

View File

@ -18,7 +18,7 @@ func (sma *StorageMongoAccessor) UpdateOne(set map[string]interface{}, id string
}
func (sma *StorageMongoAccessor) StoreOne(data utils.DBObject) (utils.DBObject, error) {
err := sma.Validate(data.(*Storage))
err := utils.Validate.Struct(data)
if err != nil {
return nil, err
}

View File

@ -18,7 +18,7 @@ func (wfa *WorkflowMongoAccessor) UpdateOne(set map[string]interface{}, id strin
}
func (wfa *WorkflowMongoAccessor) StoreOne(data utils.DBObject) (utils.DBObject, error) {
err := wfa.Validate(data.(*Workflow))
err := utils.Validate.Struct(data)
if err != nil {
return nil, err
}

View File

@ -8,7 +8,7 @@ import (
"github.com/rs/zerolog"
)
var validate = validator.New(validator.WithRequiredStructEnabled())
var Validate = validator.New(validator.WithRequiredStructEnabled())
type AbstractAccessor struct {
Logger zerolog.Logger
@ -19,10 +19,6 @@ func (dma *AbstractAccessor) GetType() string {
return dma.Type
}
func (dma *AbstractAccessor) Validate(d DBObject) error {
return validate.Struct(d)
}
func (dma *AbstractAccessor) SetLogger(t resources.ResourceType) {
dma.Logger = logs.CreateLogger(t.String(), "")
dma.Type = t.String()