core

package
v1.5.1 Latest Latest
Warning

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

Go to latest
Published: Oct 4, 2025 License: GPL-3.0 Imports: 7 Imported by: 0

Documentation

Index

Constants

View Source
const (
	Size64 int = 64
	Size32 int = 32
	Size16 int = 16
	Size8  int = 8
)
View Source
const DefaultTokenBytes int = Size32

DefaultTokenBytes defines the default length of token bytes to generate a token. This is used in the function "GenerateTokenDefaultLength"

View Source
const (
	IntBase10 int = 10
)
View Source
const OneDayDuration time.Duration = 24 * time.Hour

Variables

This section is empty.

Functions

func GenerateRandomPassword added in v1.3.6

func GenerateRandomPassword(length int) string

Generates a random password with the requested length.

func GenerateToken added in v1.2.0

func GenerateToken(numberBytes int) string

Generates a crypto random token with a number of bytes. The returned token is encoded in URL base64.

func GenerateTokenDefaultLength added in v1.2.0

func GenerateTokenDefaultLength() string

Generates a crypto random token with the default length. See the function "GenerateToken" and the constant "DefaultTokenBytes"

Types

type CustomValidationError added in v1.5.1

type CustomValidationError struct {
	ErrorMessage  string
	StructName    string
	FieldName     string
	FieldTypeName string
	FieldValue    string
	Identifier    valtruc.ValidatorIdentifier
}

func (CustomValidationError) Error added in v1.5.1

func (v CustomValidationError) Error() string

func (CustomValidationError) Format added in v1.5.1

func (v CustomValidationError) Format(f string) string

func (CustomValidationError) GetFieldName added in v1.5.1

func (v CustomValidationError) GetFieldName() string

func (CustomValidationError) GetFieldTypeName added in v1.5.1

func (v CustomValidationError) GetFieldTypeName() string

func (CustomValidationError) GetFieldValue added in v1.5.1

func (v CustomValidationError) GetFieldValue() string

func (CustomValidationError) GetIdentifier added in v1.5.1

func (CustomValidationError) GetStructName added in v1.5.1

func (v CustomValidationError) GetStructName() string

type Cypher

type Cypher interface {
	Encrypt(data []byte) ([]byte, error)
	Decrypt(data []byte) ([]byte, error)
}

Cypher is anything that implements a symmetric encription

type DomainError

type DomainError struct {
	Code    int
	Message string
	// contains filtered or unexported fields
}

DomainError models an error generated by business logic layer of your application

func (DomainError) Error

func (err DomainError) Error() string

func (DomainError) IsPresent

func (err DomainError) IsPresent() bool

func (DomainError) Wrap added in v1.4.5

func (err DomainError) Wrap(other error) DomainError

func (DomainError) Wrapf added in v1.4.5

func (err DomainError) Wrapf(format string, a ...any) DomainError

type Hasher

type Hasher interface {
	Hash(value string) (string, error)
	Check(a, b string) bool
}

Hasher is anything that implements a hash algorithm. Normally a cryptographic hash to hash passwords (eg Bcrypt)

type ModelState

type ModelState struct {
	Valid  bool
	Errors map[string][]ValidationError
}

ModelState represent the validation state of a ViewModel. Normally you want to let owl to generate it via the context API:

func handler(ctx owl.Ctx) error {
	var vm ViewModel
	ctx.ParseForm(&vm)
	ctx.Validate(vm)
	if ctx.ModelState.Valid {
		...
	}
}

The validate function fills the ModelState depending of the rules you define in the struct tags using the library 'valtruc'.

type Role

type Role int64

Role defines a user role

const (
	RoleAdmin Role = 1
	RoleUser  Role = 2
)

type ValidationError

type ValidationError interface {
	Error() string
	Format(f string) string
	GetStructName() string
	GetFieldName() string
	GetFieldTypeName() string
	GetFieldValue() string
	GetIdentifier() valtruc.ValidatorIdentifier
}

ValidationError represents an infraction of validation rules defined in tags of a struct. Show 'ModelState'.

Jump to

Keyboard shortcuts

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