This repository has been archived by the owner on Feb 26, 2024. It is now read-only.
forked from omissis/go-jsonschema
-
Notifications
You must be signed in to change notification settings - Fork 0
/
ip.go
54 lines (48 loc) · 1.37 KB
/
ip.go
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
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
// Code generated by github.com/zrma/go-jsonschema, DO NOT EDIT.
package test
import "encoding/json"
import "fmt"
import yaml "gopkg.in/yaml.v3"
import "net/netip"
// UnmarshalJSON implements json.Unmarshaler.
func (j *IpMyObject) UnmarshalJSON(value []byte) error {
var raw map[string]interface{}
if err := json.Unmarshal(value, &raw); err != nil {
return err
}
if v, ok := raw["myIp"]; !ok || v == nil {
return fmt.Errorf("field myIp in IpMyObject: required")
}
type Plain IpMyObject
var plain Plain
if err := json.Unmarshal(value, &plain); err != nil {
return err
}
*j = IpMyObject(plain)
return nil
}
// UnmarshalYAML implements yaml.Unmarshaler.
func (j *IpMyObject) UnmarshalYAML(value *yaml.Node) error {
var raw map[string]interface{}
if err := value.Decode(&raw); err != nil {
return err
}
if v, ok := raw["myIp"]; !ok || v == nil {
return fmt.Errorf("field myIp in IpMyObject: required")
}
type Plain IpMyObject
var plain Plain
if err := value.Decode(&plain); err != nil {
return err
}
*j = IpMyObject(plain)
return nil
}
type Ip struct {
// MyObject corresponds to the JSON schema field "myObject".
MyObject *IpMyObject `json:"myObject,omitempty" yaml:"myObject,omitempty" mapstructure:"myObject,omitempty"`
}
type IpMyObject struct {
// MyIp corresponds to the JSON schema field "myIp".
MyIp netip.Addr `json:"myIp" yaml:"myIp" mapstructure:"myIp"`
}