added validation; DB is global now

This commit is contained in:
$(pass /github/name)
2024-07-11 20:59:52 +02:00
parent e4475e2400
commit 03a2b3bdc5
22 changed files with 287 additions and 218 deletions

View File

@@ -5,12 +5,12 @@ import "time"
type BankAccount struct {
CreatedAt time.Time
UpdatedAt time.Time
MandateDateSigned time.Time `gorm:"not null" json:"mandate_date_signed"`
Bank string `json:"bank_name"`
AccountHolderName string `json:"account_holder_name"`
IBAN string `gorm:"not null" json:"iban"`
BIC string `json:"bic"`
MandateReference string `gorm:"not null" json:"mandate_reference"`
MandateDateSigned time.Time `gorm:"not null"` // json:"mandate_date_signed"`
Bank string //`json:"bank_name" validate:"omitempty,alphanumunicode"`
AccountHolderName string //`json:"account_holder_name" validate:"omitempty,alphaunicode"`
IBAN string `gorm:"not null" json:"iban" validate:"required,iban"`
BIC string //`json:"bic" validate:"omitempty,bic"`
MandateReference string `gorm:"not null"` //json:"mandate_reference"`
ID int64 `gorm:"primaryKey"`
UserID int64 `json:"user_id"`
UserID int64 //`json:"user_id"`
}

View File

@@ -9,7 +9,7 @@ type Membership struct {
EndDate time.Time `json:"end_date"`
Children *[]User `gorm:"foreignKey:ParentMemberID"`
Status string `json:"status"`
SubscriptionModel SubscriptionModel `gorm:"foreignKey:SubscriptionModelID"`
SubscriptionModel SubscriptionModel `gorm:"foreignKey:SubscriptionModelID" json:"subscription_model"`
SubscriptionModelID int64 `json:"subsription_model_id"`
ID int64 `json:"id"`
UserID int64 `json:"user_id"`

View File

@@ -7,12 +7,12 @@ import (
type SubscriptionModel struct {
CreatedAt time.Time
UpdatedAt time.Time
Name string `json:"name"`
Details string `json:"details"`
Conditions string `json:"conditions"`
Name string `json:"name" validate:"required,alphaunicode,subscriptionModel"`
Details string `json:"details" validate:"required"`
Conditions string `json:"conditions" validate:"required"`
ID int64 `gorm:"primaryKey"`
MonthlyFee float32 `json:"monthly_fee"`
HourlyRate float32 `json:"hourly_rate"`
IncludedPerYear int16 `json:"included_hours_per_year"`
IncludedPerMonth int16 `json:"included_hours_per_month"`
MonthlyFee float32 `json:"monthly_fee" validate:"required,number"`
HourlyRate float32 `json:"hourly_rate" validate:"required,number"`
IncludedPerYear int16 `json:"included_hours_per_year" validate:"omitempty,number"`
IncludedPerMonth int16 `json:"included_hours_per_month" validate:"omitempty,number"`
}

View File

@@ -8,24 +8,24 @@ import (
type User struct {
UpdatedAt time.Time
DateOfBirth time.Time `gorm:"not null" json:"date_of_birth"`
DateOfBirth time.Time `gorm:"not null" json:"date_of_birth" validate:"required,age"`
CreatedAt time.Time
Salt *string `json:"-"`
Phone *string `json:"phone"`
Phone string `json:"phone" validate:"omitempty,omitnil,e164"`
Notes *string `json:"notes"`
FirstName string `gorm:"not null" json:"first_name"`
FirstName string `gorm:"not null" json:"first_name" validate:"required,alphaunicode"`
Password string `json:"password"`
Email string `gorm:"unique;not null" json:"email"`
LastName string `gorm:"not null" json:"last_name"`
ProfilePicture string `json:"profile_picture"`
Address string `gorm:"not null" json:"address"`
ZipCode string `gorm:"not null" json:"zip_code"`
City string `form:"not null" json:"city"`
Email string `gorm:"unique;not null" json:"email" validate:"required,email"`
LastName string `gorm:"not null" json:"last_name" validate:"required,alphaunicode"`
ProfilePicture string `json:"profile_picture" validate:"omitempty,image"`
Address string `gorm:"not null" json:"address" validate:"required"`
ZipCode string `gorm:"not null" json:"zip_code" validate:"required,alphanum"`
City string `form:"not null" json:"city" validate:"required,alphaunicode"`
Consents []Consent `gorm:"constraint:OnUpdate:CASCADE"`
BankAccount BankAccount `gorm:"constraint:OnUpdate:CASCADE,OnDelete:CASCADE;"`
BankAccount BankAccount `gorm:"constraint:OnUpdate:CASCADE,OnDelete:CASCADE;" json:"bank_account"`
Verification Verification `gorm:"constraint:OnUpdate:CASCADE,OnDelete:CASCADE;"`
Membership Membership `gorm:"constraint:OnUpdate:CASCADE,OnDelete:CASCADE;"`
ParentMemberID int64 `json:"parent_member_id"`
Membership Membership `gorm:"constraint:OnUpdate:CASCADE,OnDelete:CASCADE;" json:"membership"`
ParentMemberID int64 `json:"parent_member_id" validate:"omitempty,number"`
ID int64 `gorm:"primaryKey"`
PaymentStatus int8 `json:"payment_status"`
Status int8 `json:"status"`