-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
d5bacf1
commit 9c0d2ff
Showing
10 changed files
with
200 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
package models | ||
|
||
import "github.com/google/uuid" | ||
|
||
type Accounts struct { | ||
ID uuid.UUID `json:"id"` | ||
UserID uint `json:"user_id"` | ||
Balance float64 `json:"balance"` | ||
MeanPayment string `json:"mean_payment"` | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
package models | ||
|
||
import ( | ||
valid "github.com/asaskevich/govalidator" | ||
"github.com/google/uuid" | ||
) | ||
|
||
type Category struct { | ||
ID uuid.UUID `json:"id" valid:"-"` | ||
UserID uint `json:"user_id" valid:"-"` | ||
Name string `json:"name" valid:"required"` | ||
} | ||
|
||
func (c *Category) CategoryValidate() error { | ||
_, err := valid.ValidateStruct(c) | ||
return err | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
package models | ||
|
||
import ( | ||
"time" | ||
|
||
valid "github.com/asaskevich/govalidator" | ||
"github.com/google/uuid" | ||
) | ||
|
||
type Credit struct { | ||
ID uuid.UUID `json:"id" valid:"-"` | ||
AccountID uint `json:"account_id" valid:"-"` | ||
Total float64 `json:"total" valid:"required,greaterzero"` | ||
DateStart time.Time `json:"date_start" valid:"isdate"` | ||
DateEnd time.Time `json:"date_end" valid:"isdate"` | ||
IsAnnuity bool `json:"is_annuity" valid:"required"` | ||
Creditor string `json:"creditor" valid:"-"` | ||
Description string `json:"description" valid:"-"` | ||
Payments int `json:"payments" valid:"-"` | ||
Bank string `json:"bank" valid:"-"` | ||
} | ||
|
||
func (c *Credit) CreditValidate() error { | ||
_, err := valid.ValidateStruct(c) | ||
return err | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
package models | ||
|
||
import ( | ||
"time" | ||
|
||
valid "github.com/asaskevich/govalidator" | ||
"github.com/google/uuid" | ||
) | ||
|
||
type Debt struct { | ||
ID uuid.UUID `json:"id" valid:"-"` | ||
UserID uint `json:"user_id" valid:"-"` | ||
Total float64 `json:"total" valid:"required,greaterzero"` | ||
Date time.Time `json:"date" valid:"isdate"` | ||
Creditor string `json:"creditor"` | ||
Description string `json:"description" valid:"-"` | ||
} | ||
|
||
func (d *Debt) DebtValidate() error { | ||
_, err := valid.ValidateStruct(d) | ||
return err | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
package models | ||
|
||
import ( | ||
"time" | ||
|
||
valid "github.com/asaskevich/govalidator" | ||
"github.com/google/uuid" | ||
) | ||
|
||
type deposit struct { | ||
ID uuid.UUID `json:"id" valid:"-"` | ||
AccountID uint `json:"account_id" valid:"-"` | ||
Total float64 `json:"total" valid:"required,greaterzero"` | ||
DateStart time.Time `json:"date_start" valid:"isdate"` | ||
DateEnd time.Time `json:"date_end" valid:"isdate"` | ||
InterestRate float64 `json:"interest_rate" valid:"required"` | ||
Bank string `json:"bank"` | ||
} | ||
|
||
func (g *Goal) GoalValidate() error { | ||
_, err := valid.ValidateStruct(g) | ||
return err | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
package models | ||
|
||
import ( | ||
"time" | ||
|
||
valid "github.com/asaskevich/govalidator" | ||
"github.com/google/uuid" | ||
) | ||
|
||
type Goal struct { | ||
ID uuid.UUID `json:"id" valid:"-"` | ||
UserID uint `json:"user_id" valid:"-"` | ||
Name string `json:"name" valid:"required"` | ||
Description string `json:"description" valid:"-"` | ||
Total float64 `json:"total" valid:"required,greaterzero"` | ||
Date time.Time `json:"date" valid:"isdate"` | ||
} | ||
|
||
func (g *Goal) GoalValidate() error { | ||
_, err := valid.ValidateStruct(g) | ||
return err | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
package models | ||
|
||
import ( | ||
"time" | ||
|
||
valid "github.com/asaskevich/govalidator" | ||
"github.com/google/uuid" | ||
) | ||
|
||
type Investment struct { | ||
ID uuid.UUID `json:"id" valid:"-"` | ||
UserID uint `json:"user_id" valid:"-"` | ||
Name string `json:"name" valid:"required"` | ||
Total float64 `json:"total" valid:"required,greaterzero"` | ||
DateStart time.Time `json:"date_start" valid:"isdate"` | ||
DateEnd time.Time `json:"date_end" valid:"isdate"` | ||
Price float64 `json:"price" valid:"required"` | ||
Percentage float64 `json:"percentage" valid:"required"` | ||
} | ||
|
||
func (i *Investment) InvestmentValidate() error { | ||
_, err := valid.ValidateStruct(i) | ||
return err | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
package models | ||
|
||
import ( | ||
"time" | ||
|
||
valid "github.com/asaskevich/govalidator" | ||
"github.com/google/uuid" | ||
) | ||
|
||
type Transaction struct { | ||
ID uuid.UUID `json:"id" valid:"-"` | ||
UserID uint `json:"user_id" valid:"-"` | ||
CategoryID uint `json:"category_id" valid:"-"` | ||
AccountID uint `json:"account_id" valid:"-"` | ||
Total float64 `json:"total" valid:"required,greaterzero"` | ||
IsIncome bool `json:"is_income" valid:"required"` | ||
Date time.Time `json:"date" valid:"isdate"` | ||
Payer string `json:"payer" valid:"payer"` | ||
Description string `json:"description" valid:"-"` | ||
} | ||
|
||
func (t *Transaction) TransactionValidate() error { | ||
_, err := valid.ValidateStruct(t) | ||
return err | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
package models | ||
|
||
import ( | ||
valid "github.com/asaskevich/govalidator" | ||
"github.com/google/uuid" | ||
) | ||
|
||
type Sex string | ||
|
||
const ( | ||
Male Sex = "M" | ||
Female Sex = "F" | ||
Other Sex = "O" // :-) | ||
) | ||
|
||
type User struct { | ||
ID uuid.UUID `json:"id" valid:"-"` | ||
Username string `json:"name" valid:"-"` | ||
Email string `json:"email" valid:"required,email"` | ||
FirstName string `json:"firstName" valid:"required,runelength(2|20)"` | ||
LastName string `json:"lastName" valid:"required,runelength(2|20)"` | ||
Password string `json:"password" valid:"required,runelength(7|30),passwordcheck"` | ||
Sex Sex `json:"sex" valid:"required,in(F|M|O)"` | ||
AvatarURL string `json:"avatar_url" vaild:"-"` | ||
} | ||
|
||
func (u *User) UserValidate() error { | ||
_, err := valid.ValidateStruct(u) | ||
return err | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
// TO DO isdate, greaterzero, passwordcheck |