utils

package
v0.0.0-...-2555d15 Latest Latest
Warning

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

Go to latest
Published: Jun 27, 2025 License: GPL-2.0 Imports: 13 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ERR_ADMINS_ONLY = "admins_only"
View Source
var ERR_ALREADY_BOUGHT = "already_bought"
View Source
var ERR_ALREADY_REVIEWED = "already_reviewed"
View Source
var ERR_ALREADY_VOTED = "already_voted"
View Source
var ERR_AUTHORS_ONLY = "authors_only"
View Source
var ERR_CONTRACT_ALREADY_APPROVED = "contract_already_approved"
View Source
var ERR_EXPIRED_OTP = "expired_otp"
View Source
var ERR_EXPIRED_TOKEN = "expired_token"
View Source
var ERR_INCORRECT_EMAIL = "incorrect_email"
View Source
var ERR_INCORRECT_OTP = "incorrect_otp"
View Source
var ERR_INCORRECT_TOKEN = "incorrect_token"
View Source
var ERR_INSUFFICIENT_COINS = "insufficient_coins"
View Source
var ERR_INSUFFICIENT_LANTERNS = "insufficient_lanterns"
View Source
var ERR_INVALID_AUTH = "invalid_auth"
View Source
var ERR_INVALID_CREDENTIALS = "invalid_credentials"
View Source
var ERR_INVALID_DATA_TYPE = "invalid_data_type"
View Source
var ERR_INVALID_ENTRY = "invalid_entry"
View Source
var ERR_INVALID_OWNER = "invalid_owner"
View Source
var ERR_INVALID_PAGE = "invalid_page"
View Source
var ERR_INVALID_PARAM = "invalid_param"
View Source
var ERR_INVALID_PAYLOAD = "invalid_payload"
View Source
var ERR_INVALID_REQUEST = "invalid_request"
View Source
var ERR_INVALID_TOKEN = "invalid_token"
View Source
var ERR_INVALID_VALUE = "invalid_value"
View Source
var ERR_LIMITS_REACHED = "limits_reached"
View Source
var ERR_NETWORK_FAILURE = "network_failure"
View Source
var ERR_NON_EXISTENT = "non_existent"
View Source
var ERR_NOT_ALLOWED = "not_allowed"
View Source
var ERR_NOT_FOUND = "not_found"
View Source
var ERR_PASSWORD_MISMATCH = "password_does_not_match"
View Source
var ERR_PASSWORD_SAME = "same_password"
View Source
var ERR_SERVER_ERROR = "server_error"
View Source
var ERR_UNAUTHORIZED_USER = "unauthorized_user"

Error codes

View Source
var ERR_UNVERIFIED_USER = "unverified_user"

Functions

func AccountTypeValidator

func AccountTypeValidator(fl validator.FieldLevel) bool

Validates if a account type value is the correct one

func AgeDiscretionValidator

func AgeDiscretionValidator(fl validator.FieldLevel) bool

Validates if a age discretion value is the correct one

func CheckPasswordHash

func CheckPasswordHash(password, hash string) bool

func ContractIDTypeChoiceValidator

func ContractIDTypeChoiceValidator(fl validator.FieldLevel) bool

Validates if a contract idtype choice value is the correct one

func ContractStatusChoiceValidator

func ContractStatusChoiceValidator(fl validator.FieldLevel) bool

Validates if a contract status choice value is the correct one

func ContractTypeChoiceValidator

func ContractTypeChoiceValidator(fl validator.FieldLevel) bool

Validates if a contract type choice value is the correct one

func ConvertStructData

func ConvertStructData(object interface{}, targetStruct interface{}) interface{}

Converting struct type to another provided the field names are the same

func CountWords

func CountWords(text string) int

func DeviceTypeValidator

func DeviceTypeValidator(fl validator.FieldLevel) bool

Validates if a device type value is the correct one

func FeaturedContentLocationChoiceValidator

func FeaturedContentLocationChoiceValidator(fl validator.FieldLevel) bool

Validates if a featured content location choice value is the correct one

func GetRandomInt

func GetRandomInt(size int) uint

Generates a random integer with a specified number of digits

func GetRandomString

func GetRandomString(length int) string

func HashPassword

func HashPassword(password string) string

func PaymentTypeValidator

func PaymentTypeValidator(fl validator.FieldLevel) bool

Validates if a payment type value is the correct one

func RatingChoiceValidator

func RatingChoiceValidator(fl validator.FieldLevel) bool

Validates if a rating choice value is the correct one

func RegisterTagName

func RegisterTagName()

func ReplyTypeValidator

func ReplyTypeValidator(fl validator.FieldLevel) bool

Validates if a reply type value is the correct one

func SubscriptionTypeValidator

func SubscriptionTypeValidator(fl validator.FieldLevel) bool

Validates if a subscription type value is the correct one

func Title

func Title(s string) string

func WordCountMaxValidator

func WordCountMaxValidator(fl validator.FieldLevel) bool

WordCountMaxValidator validates maximum word count

func WordCountMinValidator

func WordCountMinValidator(fl validator.FieldLevel) bool

WordCountMinValidator validates minimum word count

Types

type CustomValidator

type CustomValidator struct{}

CustomValidator is a custom validator that uses "github.com/go-playground/validator/v10"

func Validator

func Validator() *CustomValidator

New creates a new instance of CustomValidator

func (*CustomValidator) Validate

func (cv *CustomValidator) Validate(i interface{}) *ErrorResponse

Validate performs the validation of the given struct

type ErrorResponse

type ErrorResponse struct {
	Status  string             `json:"status"`
	Code    string             `json:"code"`
	Message string             `json:"message"`
	Data    *map[string]string `json:"data,omitempty"`
}

func InvalidParamErr

func InvalidParamErr(message string) ErrorResponse

func NotFoundErr

func NotFoundErr(message string) ErrorResponse

func RateLimitError

func RateLimitError(message string) ErrorResponse

func RequestErr

func RequestErr(code string, message string, opts ...map[string]string) ErrorResponse

func ServerErr

func ServerErr(message string) ErrorResponse

func ValidationErr

func ValidationErr(field string, message string) ErrorResponse

func (*ErrorResponse) Error

func (e *ErrorResponse) Error() string

Jump to

Keyboard shortcuts

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