File size: 694 Bytes
1e92f2d |
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 |
package escalation
import (
"github.com/target/goalert/validation/validate"
)
type Policy struct {
ID string `json:"id"`
Name string `json:"name"`
Description string `json:"description"`
Repeat int `json:"repeat"`
isUserFavorite bool
}
func (p Policy) Normalize() (*Policy, error) {
err := validate.Many(
validate.IDName("Name", p.Name),
validate.Text("Description", p.Description, 1, 255),
validate.Range("Repeat", p.Repeat, 0, 5),
)
if err != nil {
return nil, err
}
return &p, nil
}
// IsUserFavorite returns true if this policy is a favorite of the current user.
func (p Policy) IsUserFavorite() bool {
return p.isUserFavorite
}
|