-
Notifications
You must be signed in to change notification settings - Fork 0
/
user_enum.go
55 lines (47 loc) · 1.2 KB
/
user_enum.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
// Code generated by go-enum DO NOT EDIT.
// Version:
// Revision:
// Build Date:
// Built By:
package malak
import (
"errors"
"fmt"
)
const (
// RoleAdmin is a Role of type admin.
RoleAdmin Role = "admin"
// RoleMember is a Role of type member.
RoleMember Role = "member"
// RoleBilling is a Role of type billing.
RoleBilling Role = "billing"
// RoleInvestor is a Role of type investor.
RoleInvestor Role = "investor"
// RoleGuest is a Role of type guest.
RoleGuest Role = "guest"
)
var ErrInvalidRole = errors.New("not a valid Role")
// String implements the Stringer interface.
func (x Role) String() string {
return string(x)
}
// IsValid provides a quick way to determine if the typed value is
// part of the allowed enumerated values
func (x Role) IsValid() bool {
_, err := ParseRole(string(x))
return err == nil
}
var _RoleValue = map[string]Role{
"admin": RoleAdmin,
"member": RoleMember,
"billing": RoleBilling,
"investor": RoleInvestor,
"guest": RoleGuest,
}
// ParseRole attempts to convert a string to a Role.
func ParseRole(name string) (Role, error) {
if x, ok := _RoleValue[name]; ok {
return x, nil
}
return Role(""), fmt.Errorf("%s is %w", name, ErrInvalidRole)
}