func (r Requirement) Validate() error {
	if r.Type == "" {
		return errors.New("type is missing")
	}
	if len(r.Name) < 3 {
		return errors.New("name is too short or not set")
	}
	return nil
}
Validate validates the fields of a module requirement
package module
import (
	"context"
	"errors"
	"fmt"
	"regexp"
	"strings"
	"time"
	"github.com/tarkov-database/rest-api/core/database"
	"github.com/tarkov-database/rest-api/model"
	"github.com/tarkov-database/rest-api/model/item"
	"github.com/google/logger"
	"go.mongodb.org/mongo-driver/bson"
	"go.mongodb.org/mongo-driver/bson/primitive"
	"go.mongodb.org/mongo-driver/mongo"
	"go.mongodb.org/mongo-driver/mongo/options"
)
type objectID = model.ObjectID
type timestamp = model.Timestamp
type Module struct {
	ID            objectID  `json:"_id" bson:"_id"`
	Name          string    `json:"name" bson:"name"`
	RequiresPower bool      `json:"requiresPower" bson:"requiresPower"`
	Stages        []Stage   `json:"stages" bson:"stages"`
	Modified      timestamp `json:"_modified" bson:"_modified"`
}
func (m Module) Validate() error {
	if len(m.Stages) == 0 {
		return errors.New("stages missing")
	}
	for i, v := range m.Stages {
		if err := v.Validate(); err != nil {
			return fmt.Errorf("validation error in stages index \"%v\": %s", i, err)
		}
	}
	return nil
}
type Stage struct {
	Description      string        `json:"description" bson:"description"`
	Bonuses          []Bonus       `json:"bonuses" bson:"bonuses"`
	Requirements     []Requirement `json:"requirements" bson:"requirements"`
	RequiredModules  []Ref         `json:"requiredMods" bson:"requiredMods"`
	Materials        []ItemRef     `json:"materials" bson:"materials"`
	ConstructionTime int64         `json:"constructionTime" bson:"constructionTime"`
}
func (s Stage) Validate() error {
	for i, v := range s.Requirements {
		if err := v.Validate(); err != nil {
			return fmt.Errorf("validation error in requirements index \"%v\": %s", i, err)
		}
	}
	for i, v := range s.RequiredModules {
		if err := v.Validate(); err != nil {
			return fmt.Errorf("validation error in required modules index \"%v\": %s", i, err)
		}
	}
	for i, v := range s.Materials {
		if err := v.Validate(); err != nil {
			return fmt.Errorf("validation error in materials index \"%v\": %s", i, err)
		}
	}
	return nil
}
type Bonus struct {
	Description string  `json:"description" bson:"description"`
	Value       float64 `json:"value,omitempty" bson:"value,omitempty"`
	SkillType   string  `json:"skillType,omitempty" bson:"skillType,omitempty"`
	Type        string  `json:"type" bson:"type"`
}
func (b Bonus) Validate() error {
	if b.Type == "" {
		return errors.New("type is missing")
	}
	if len(b.Description) < 3 {
		return errors.New("name is too short or not set")
	}
	return nil
}
type Requirement struct {
	Name  string `json:"name" bson:"name"`
	Level uint8  `json:"level,omitempty" bson:"level,omitempty"`
	Type  string `json:"type" bson:"type"`
}