utils

package
v0.0.0-...-a6fb04e Latest Latest
Warning

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

Go to latest
Published: Dec 7, 2024 License: GPL-2.0 Imports: 12 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_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 ChapterStatusValidator

func ChapterStatusValidator(fl validator.FieldLevel) bool

Validates if a chapter status 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 GetRandomInt

func GetRandomInt(size int) int

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 SubscriptionTypeValidator

func SubscriptionTypeValidator(fl validator.FieldLevel) bool

Validates if a subscription type value is the correct one

func Title

func Title(s string) string

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 NotFoundErr

func NotFoundErr(message string) ErrorResponse

func RequestErr

func RequestErr(code string, message string, opts ...map[string]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