2021-04-22 08:35:24 +02:00
|
|
|
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 `.`.
|
2021-04-24 21:36:11 +02:00
|
|
|
ZoneName string
|
2021-04-22 08:35:24 +02:00
|
|
|
)
|
|
|
|
|
2021-04-24 21:36:11 +02:00
|
|
|
func (z *ZoneName) UnmarshalJSON(in []byte) error {
|
2021-04-22 08:35:24 +02:00
|
|
|
in = bytes.Trim(in, `"`)
|
|
|
|
|
|
|
|
if in[len(in)-1] != '.' {
|
|
|
|
return fmt.Errorf("not a valid zone name")
|
|
|
|
}
|
2021-04-24 21:36:11 +02:00
|
|
|
*z = ZoneName(in)
|
2021-04-22 08:35:24 +02:00
|
|
|
return nil
|
|
|
|
}
|