zitadel/internal/v2/org/state.go
Silvan 12be21a3ff
refactor(v2): init events (#7823)
creates events structures for initial projections and read models
2024-05-23 06:36:08 +02:00

37 lines
529 B
Go

package org
type State uint8
const (
UndefinedState State = iota
ActiveState
InactiveState
RemovedState
maxState
)
func (s State) IsValid() bool {
return s != UndefinedState ||
s < maxState
}
func (s State) Is(state State) bool {
return s == state
}
func (s State) IsValidState(state State) bool {
return s.IsValid() && s.Is(state)
}
func (s State) IsValidStates(states ...State) bool {
if !s.IsValid() {
return false
}
for _, state := range states {
if s.Is(state) {
return true
}
}
return false
}