dim/types/zone.go

22 lines
313 B
Go

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