// Code generated by github.com/atombender/go-jsonschema, DO NOT EDIT.

package test

import "encoding/json"
import "fmt"
import yaml "gopkg.in/yaml.v3"
import "net/netip"

type Ip struct {
	// MyObject corresponds to the JSON schema field "myObject".
	MyObject *IpMyObject `json:"myObject,omitempty,omitzero" 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"`
}

// 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 _, ok := raw["myIp"]; raw != nil && !ok {
		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 _, ok := raw["myIp"]; raw != nil && !ok {
		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
}
