dim/types/zone.go

26 lines
382 B
Go
Raw Normal View History

package types
import (
"bytes"
"fmt"
)
type (
2021-04-22 08:42:33 +02:00
// Zone represents the name of a zone. A zone must end with a `.`.
ZoneName string
)
func (z *ZoneName) UnmarshalJSON(in []byte) error {
in = bytes.Trim(in, `"`)
if in[len(in)-1] != '.' {
return fmt.Errorf("not a valid zone name")
}
*z = ZoneName(in)
return nil
}
func (z ZoneName) String() string {
return string(z)
}