Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func RequiredEntry ¶
RequiredEntry can be used as a scope to return a custom error if the entry id associated with the expense doesn't exist.
func ValidateModel ¶
func ValidateModel(model ModelValidator) func(db *gorm.DB) *gorm.DB
ValidateModel can be used as a scope to validate any of the existing GORM models, that implement the ModelValidator interface.
Types ¶
type Debt ¶
Debt models a debt owed to or held by someone. Fields are automatically mapped by gorm to their database equivalents.
func (*Debt) AfterDelete ¶
AfterDelete is a gorm hook that adds an error if the debt was not found during an delete operation. This implicitly assumes that the delete query executes with a "returning" clause that writes to an empty debt.
func (*Debt) AfterUpdate ¶
AfterUpdate is a gorm hook that adds an error if the debt was not found during an update operation. This implicitly assumes that the update query executes with a "returning" clause that writes to an empty debt.
type Entry ¶
type Entry struct { BaseModel Value Month int Year int Category string Subcategory string Recurring bool Expenses []Expense }
Entry models an entry of a planning. Fields are automatically mapped by gorm to their database equivalents.
func (*Entry) AfterDelete ¶
AfterDelete is a gorm hook that adds an error if the entry was not found during an delete operation. This implicitly assumes that the delete query executes with a "returning" clause that writes to an empty entry.
func (*Entry) AfterUpdate ¶
AfterUpdate is a gorm hook that adds an error if the entry was not found during an update operation. This implicitly assumes that the update query executes with a "returning" clause that writes to an empty entry.
type ErrExpenseInvalidEntryKey ¶
type ErrExpenseInvalidEntryKey struct {
// contains filtered or unexported fields
}
func (ErrExpenseInvalidEntryKey) Error ¶
func (e ErrExpenseInvalidEntryKey) Error() string
type ErrInvalidModel ¶
type ErrInvalidModel struct {
// contains filtered or unexported fields
}
ErrInvalidModel stores the data of a model validation error. The reasons are included to provide all issues that occured during validation.
func NewBaseModelError ¶
func NewBaseModelError(prefix string, reasons []string) ErrInvalidModel
func (ErrInvalidModel) Error ¶
func (b ErrInvalidModel) Error() string
type Expense ¶
type Expense struct { BaseModel Value EntryId int Name string Description string PaymentMethod string }
Expense models an expense that can be associated with an entry. Fields are automatically mapped by gorm to their database equivalents.
func (*Expense) AfterDelete ¶
AfterDelete is a gorm hook that adds an error if the expense was not found during an delete operation. This implicitly assumes that the delete query executes with a "returning" clause that writes to an empty expense.
func (*Expense) AfterUpdate ¶
AfterUpdate is a gorm hook that adds an error if the expense was not found during an update operation. This implicitly assumes that the update query executes with a "returning" clause that writes to an empty expense.
type InvalidModelErrBuilder ¶
type InvalidModelErrBuilder struct {
// contains filtered or unexported fields
}
InvalidModelErrBuilder can be used to create detailed model validation errors, by adding each individual error after instantiating a builder.
func NewBaseModelErrorBuilder ¶
func NewBaseModelErrorBuilder(modelName string) *InvalidModelErrBuilder
func (*InvalidModelErrBuilder) AddError ¶
func (b *InvalidModelErrBuilder) AddError(err string)
func (*InvalidModelErrBuilder) Error ¶
func (b *InvalidModelErrBuilder) Error() error
type ModelValidator ¶
type ModelValidator interface {
Validate() error
}
ModelValidator is the interface all models implement to throws