Implement domain layer (TDD - Green phase)
Implementation to make all tests pass: Value Objects: - HabitType: BOOLEAN, COUNTER, VALUE with validation - Frequency: DAILY, WEEKLY, MONTHLY with validation Entities: - User: email, password hash, timezone with defaults - Habit: tracking habits with type, frequency, carry-over - HabitEntry: recording habit completions with soft delete Repositories (interfaces): - UserRepository: CRUD operations for users - HabitRepository: CRUD operations for habits - HabitEntryRepository: CRUD operations for entries Shared: - Common error definitions for domain layer All domain tests now pass.
This commit is contained in:
@@ -0,0 +1,17 @@
|
||||
package value_objects
|
||||
|
||||
type Frequency string
|
||||
|
||||
const (
|
||||
FrequencyDaily Frequency = "DAILY"
|
||||
FrequencyWeekly Frequency = "WEEKLY"
|
||||
FrequencyMonthly Frequency = "MONTHLY"
|
||||
)
|
||||
|
||||
func (f Frequency) IsValid() bool {
|
||||
switch f {
|
||||
case FrequencyDaily, FrequencyWeekly, FrequencyMonthly:
|
||||
return true
|
||||
}
|
||||
return false
|
||||
}
|
||||
@@ -0,0 +1,17 @@
|
||||
package value_objects
|
||||
|
||||
type HabitType string
|
||||
|
||||
const (
|
||||
HabitTypeBoolean HabitType = "BOOLEAN"
|
||||
HabitTypeCounter HabitType = "COUNTER"
|
||||
HabitTypeValue HabitType = "VALUE"
|
||||
)
|
||||
|
||||
func (ht HabitType) IsValid() bool {
|
||||
switch ht {
|
||||
case HabitTypeBoolean, HabitTypeCounter, HabitTypeValue:
|
||||
return true
|
||||
}
|
||||
return false
|
||||
}
|
||||
Reference in New Issue
Block a user