Documentation
¶
Index ¶
- Constants
- func GenerateRandomPassword(length int) string
- func GenerateToken(numberBytes int) string
- func GenerateTokenDefaultLength() string
- type CustomValidationError
- func (v CustomValidationError) Error() string
- func (v CustomValidationError) Format(f string) string
- func (v CustomValidationError) GetFieldName() string
- func (v CustomValidationError) GetFieldTypeName() string
- func (v CustomValidationError) GetFieldValue() string
- func (v CustomValidationError) GetIdentifier() valtruc.ValidatorIdentifier
- func (v CustomValidationError) GetStructName() string
- type Cypher
- type DomainError
- type Hasher
- type ModelState
- type Role
- type ValidationError
Constants ¶
const ( Size64 int = 64 Size32 int = 32 Size16 int = 16 Size8 int = 8 )
const DefaultTokenBytes int = Size32
DefaultTokenBytes defines the default length of token bytes to generate a token. This is used in the function "GenerateTokenDefaultLength"
const (
IntBase10 int = 10
)
const OneDayDuration time.Duration = 24 * time.Hour
Variables ¶
This section is empty.
Functions ¶
func GenerateRandomPassword ¶ added in v1.3.6
Generates a random password with the requested length.
func GenerateToken ¶ added in v1.2.0
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 (v CustomValidationError) GetIdentifier() valtruc.ValidatorIdentifier
func (CustomValidationError) GetStructName ¶ added in v1.5.1
func (v CustomValidationError) GetStructName() string
type DomainError ¶
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 ¶
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 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'.