models

package
v0.0.0-...-d4b65f6 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jan 25, 2024 License: MIT Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var Classifications = []TextClassification{"irrelevant",
	"obscene",
	"illegal",
	"insulting",
	"unsorted",
	"approved",
}

Functions

func ValidateLength

func ValidateLength(fieldName string, fieldValue string, minLen int, maxLen int) error

ValidateLength checks if the length of the field is within the specified range.

func ValidateRequired

func ValidateRequired(fieldName string, fieldValue string) error

ValidateRequired checks if the field is required and not empty.

Types

type PM

type PM struct {
	ID             int
	Content        string
	Created        time.Time
	SenderUserID   int
	ReceiverUserID int
	SenderName     string
	ReceiverName   string
}

func (*PM) ValidatePM

func (pm *PM) ValidatePM(config ValidationConfig) []error

type Post

type Post struct {
	ID             int
	Subject        string
	Content        string
	Created        time.Time
	ThreadId       int
	UserID         int
	Image          string
	Classification string
}

func (*Post) Validate

func (post *Post) Validate(config ValidationConfig) []error

Validate performs validation on the thread struct. It checks for the presence of required fields and validates the length format. Returns a slice of errors, where each error represents a validation issue.

type PostDataForThemePage

type PostDataForThemePage struct {
	ID                        int
	Subject                   string
	Content                   string
	Image                     string
	Created                   string
	UserNameWhoCreatedPost    string
	UserIDWhoCreatedPost      int
	PictureUserWhoCreatedPost string
	UserRegistrationDate      string
	UserPostsAmmount          int
	Likes                     int
	Dislikes                  int
	Classification            string
}

type TemplateData

type TemplateData struct {
	StringMap map[string]string
	IntMap    map[string]int
	FloatMap  map[string]float32
	Data      map[string]interface{}
	//cross site request forgery token (security token)
	CSRFToken string
	//dif kind of messages
	Flash   string
	Warning string
	Error   string
	Form    *forms.Form
}

type TextClassification

type TextClassification string

CommentType represents the type of a comment

type Thread

type Thread struct {
	ID             int
	Subject        string
	Created        time.Time
	UserID         int
	Image          string
	Category       string
	Classification string
}

func (*Thread) Validate

func (thread *Thread) Validate(config ValidationConfig) []error

Validate performs validation on the thread struct. It checks for the presence of required fields and validates the length format. Returns a slice of errors, where each error represents a validation issue.

type ThreadDataForMainPage

type ThreadDataForMainPage struct {
	Subject                       string
	Created                       string
	UserNameWhoCreatedThread      string
	UserNameWhoCreatedLastPost    string
	PictureUserWhoCreatedThread   string
	PictureUserWhoCreatedLastPost string
	Posts                         []Post
	ThreadID                      int
	Image                         string
	Category                      string
	Classification                string
	UserID                        int
}

type User

type User struct {
	ID           int
	UserName     string
	Password     string
	FirstName    string
	LastName     string
	Email        string
	Created      time.Time
	Picture      string
	LastActivity time.Time
	Type         string
}

func (*User) Validate

func (u *User) Validate(config ValidationConfig) []error

Validate performs validation on the User struct. It checks for the presence of required fields and validates the email format. Returns a slice of errors, where each error represents a validation issue.

type Validatable

type Validatable interface {
	Validate() []error
}

type ValidationConfig

type ValidationConfig struct {
	MinLen           int
	MaxLen           int
	PasswordMinLen   int
	PasswordMaxLen   int
	MinCategoryLen   int
	MaxCategoryLen   int
	MinSubjectLen    int
	MaxSubjectLen    int
	SingleWordMaxLen int
}

ValidationConfig holds configuration parameters for validation.

type Votes

type Votes struct {
	ID        int
	UpCount   int
	DownCount int
	PostId    int
}

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL