types.NotificationTypes: Implement UnmarshalText()

This commit is contained in:
Noah Hilverling 2021-04-22 09:53:47 +02:00
parent 9e3a8b4d1d
commit 26c889ad66

View file

@ -2,6 +2,7 @@ package types
import (
"database/sql/driver"
"encoding"
"encoding/json"
"fmt"
)
@ -29,6 +30,11 @@ func (nt *NotificationTypes) UnmarshalJSON(bytes []byte) error {
return nil
}
// UnmarshalText implements the encoding.TextUnmarshaler interface.
func (nt *NotificationTypes) UnmarshalText(text []byte) error {
return nt.UnmarshalJSON(text)
}
// Value implements the driver.Valuer interface.
func (nt NotificationTypes) Value() (driver.Value, error) {
if nt&^allNotificationTypes == 0 {
@ -73,7 +79,8 @@ var allNotificationTypes = func() NotificationTypes {
// Assert interface compliance.
var (
_ error = BadNotificationTypes{}
_ json.Unmarshaler = (*NotificationTypes)(nil)
_ driver.Valuer = NotificationTypes(0)
_ error = BadNotificationTypes{}
_ json.Unmarshaler = (*NotificationTypes)(nil)
_ encoding.TextUnmarshaler = (*NotificationTypes)(nil)
_ driver.Valuer = NotificationTypes(0)
)