dto

package
v1.1.7 Latest Latest
Warning

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

Go to latest
Published: Jul 1, 2024 License: Apache-2.0 Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type CreateBlog

type CreateBlog struct {
	Title       string   `json:"title" validate:"required,min=3,max=500"`
	Description string   `json:"description" validate:"required,min=3,max=2000"`
	DraftText   string   `json:"draftText" validate:"required,max=50000"`
	Slug        string   `json:"slug" validate:"required,min=3,max=200"`
	ImgURL      string   `json:"imgUrl" validate:"required,uri,max=200"`
	Tags        []string `json:"tags" validate:"required,min=1,dive,uppercase"`
}

func EmptyCreateBlog

func EmptyCreateBlog() *CreateBlog

func (*CreateBlog) GetValue

func (d *CreateBlog) GetValue() *CreateBlog

func (*CreateBlog) ValidateErrors

func (b *CreateBlog) ValidateErrors(errs validator.ValidationErrors) ([]string, error)

type InfoAuthor

type InfoAuthor struct {
	ID            primitive.ObjectID `json:"_id" binding:"required" validate:"required"`
	Name          string             `json:"name" binding:"required" validate:"required"`
	ProfilePicURL *string            `json:"profilePicUrl,omitempty" validate:"omitempty,url"`
}

func NewInfoPrivateUser

func NewInfoPrivateUser(user *model.User) *InfoAuthor

func (*InfoAuthor) GetValue

func (d *InfoAuthor) GetValue() *InfoAuthor

func (*InfoAuthor) ValidateErrors

func (d *InfoAuthor) ValidateErrors(errs validator.ValidationErrors) ([]string, error)

type InfoBlog

type InfoBlog struct {
	ID          primitive.ObjectID `json:"_id" binding:"required" validate:"required"`
	Title       string             `json:"title" validate:"required,min=3,max=500"`
	Description string             `json:"description" validate:"required,min=3,max=2000"`
	Slug        string             `json:"slug" validate:"required,min=3,max=200"`
	ImgURL      *string            `json:"imgUrl,omitempty" validate:"omitempty,uri,max=200"`
	Score       float64            `json:"score," validate:"required,min=0,max=1"`
	Tags        []string           `json:"tags" validate:"required,dive,uppercase"`
}

func EmptyInfoBlog

func EmptyInfoBlog() *InfoBlog

func NewInfoBlog

func NewInfoBlog(blog *model.Blog) (*InfoBlog, error)

func (*InfoBlog) GetValue

func (d *InfoBlog) GetValue() *InfoBlog

func (*InfoBlog) ValidateErrors

func (b *InfoBlog) ValidateErrors(errs validator.ValidationErrors) ([]string, error)

type PrivateBlog

type PrivateBlog struct {
	ID          primitive.ObjectID `json:"_id" binding:"required" validate:"required"`
	Title       string             `json:"title" validate:"required,min=3,max=500"`
	Description string             `json:"description" validate:"required,min=3,max=2000"`
	Text        *string            `json:"text,omitempty" validate:"omitempty,max=50000"`
	DraftText   string             `json:"draftText" validate:"required"`
	Slug        string             `json:"slug" validate:"required,min=3,max=200"`
	Author      *InfoAuthor        `json:"author,omitempty" validate:"required,omitempty"`
	ImgURL      *string            `json:"imgUrl,omitempty" validate:"omitempty,uri,max=200"`
	Score       *float64           `json:"score,omitempty" validate:"omitempty,min=0,max=1"`
	Tags        *[]string          `json:"tags,omitempty" validate:"omitempty,dive,uppercase"`
	Submitted   bool               `json:"submitted" validate:"required"`
	Drafted     bool               `json:"drafted" validate:"required"`
	Published   bool               `json:"published" validate:"required"`
	PublishedAt *time.Time         `json:"publishedAt,omitempty"`
	CreatedAt   time.Time          `json:"createdAt" validate:"required"`
	UpdatedAt   time.Time          `json:"updatedAt" validate:"required"`
}

func EmptyInfoPrivateBlog

func EmptyInfoPrivateBlog() *PrivateBlog

func NewPrivateBlog

func NewPrivateBlog(blog *model.Blog, author *userModel.User) (*PrivateBlog, error)

func (*PrivateBlog) GetValue

func (d *PrivateBlog) GetValue() *PrivateBlog

func (*PrivateBlog) ValidateErrors

func (b *PrivateBlog) ValidateErrors(errs validator.ValidationErrors) ([]string, error)

type PublicBlog

type PublicBlog struct {
	ID          primitive.ObjectID `json:"_id" binding:"required" validate:"required"`
	Title       string             `json:"title" validate:"required,min=3,max=500"`
	Description string             `json:"description" validate:"required,min=3,max=2000"`
	Text        string             `json:"text" validate:"required,max=50000"`
	Slug        string             `json:"slug" validate:"required,min=3,max=200"`
	Author      *InfoAuthor        `json:"author,omitempty" validate:"required,omitempty"`
	ImgURL      *string            `json:"imgUrl,omitempty" validate:"omitempty,uri,max=200"`
	Score       *float64           `json:"score,omitempty" validate:"omitempty,min=0,max=1"`
	Tags        *[]string          `json:"tags,omitempty" validate:"omitempty,dive,uppercase"`
	PublishedAt *time.Time         `json:"publishedAt,omitempty"`
}

func EmptyInfoPublicBlog

func EmptyInfoPublicBlog() *PublicBlog

func NewPublicBlog

func NewPublicBlog(blog *model.Blog, author *userModel.User) (*PublicBlog, error)

func (*PublicBlog) GetValue

func (d *PublicBlog) GetValue() *PublicBlog

func (*PublicBlog) ValidateErrors

func (b *PublicBlog) ValidateErrors(errs validator.ValidationErrors) ([]string, error)

type UpdateBlog

type UpdateBlog struct {
	ID          primitive.ObjectID `json:"_id" binding:"required" validate:"required"`
	Title       *string            `json:"title" validate:"omitempty,min=3,max=500"`
	Description *string            `json:"description" validate:"omitempty,min=3,max=2000"`
	DraftText   *string            `json:"draftText" validate:"omitempty,max=50000"`
	Slug        *string            `json:"slug" validate:"omitempty,min=3,max=200"`
	ImgURL      *string            `json:"imgUrl" validate:"omitempty,uri,max=200"`
	Tags        *[]string          `json:"tags" validate:"omitempty,min=1,dive,uppercase"`
}

func EmptyUpdateBlog

func EmptyUpdateBlog() *UpdateBlog

func (*UpdateBlog) GetValue

func (d *UpdateBlog) GetValue() *UpdateBlog

func (*UpdateBlog) ValidateErrors

func (b *UpdateBlog) ValidateErrors(errs validator.ValidationErrors) ([]string, error)

Jump to

Keyboard shortcuts

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