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

package test

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

type OmitBoth struct {
	// MyArray corresponds to the JSON schema field "myArray".
	MyArray []interface{} `json:"myArray,omitempty,omitzero"`

	// MyBoolean corresponds to the JSON schema field "myBoolean".
	MyBoolean *bool `json:"myBoolean,omitempty,omitzero"`

	// MyInteger corresponds to the JSON schema field "myInteger".
	MyInteger *int `json:"myInteger,omitempty,omitzero"`

	// MyMap corresponds to the JSON schema field "myMap".
	MyMap OmitBothMyMap `json:"myMap,omitempty,omitzero"`

	// MyNull corresponds to the JSON schema field "myNull".
	MyNull interface{} `json:"myNull,omitempty,omitzero"`

	// MyNullArray corresponds to the JSON schema field "myNullArray".
	MyNullArray []interface{} `json:"myNullArray,omitempty,omitzero"`

	// MyNumber corresponds to the JSON schema field "myNumber".
	MyNumber *float64 `json:"myNumber,omitempty,omitzero"`

	// MyObjectArray corresponds to the JSON schema field "myObjectArray".
	MyObjectArray []OmitBothMyObjectArrayElem `json:"myObjectArray,omitempty,omitzero"`

	// MyString corresponds to the JSON schema field "myString".
	MyString *string `json:"myString,omitempty,omitzero"`

	// MyStringArray corresponds to the JSON schema field "myStringArray".
	MyStringArray []string `json:"myStringArray,omitempty,omitzero"`
}

type OmitBothMyMap map[string]float64

type OmitBothMyObjectArrayElem map[string]interface{}

// UnmarshalJSON implements json.Unmarshaler.
func (j *OmitBoth) UnmarshalJSON(value []byte) error {
	var raw map[string]interface{}
	if err := json.Unmarshal(value, &raw); err != nil {
		return err
	}
	type Plain OmitBoth
	var plain Plain
	if err := json.Unmarshal(value, &plain); err != nil {
		return err
	}
	if plain.MyNull != nil {
		return fmt.Errorf("field %s: must be null", "myNull")
	}
	for i0 := range plain.MyNullArray {
		if plain.MyNullArray[i0] != nil {
			return fmt.Errorf("field %s: must be null", fmt.Sprintf("myNullArray[%d]", i0))
		}
	}
	*j = OmitBoth(plain)
	return nil
}

// UnmarshalYAML implements yaml.Unmarshaler.
func (j *OmitBoth) UnmarshalYAML(value *yaml.Node) error {
	var raw map[string]interface{}
	if err := value.Decode(&raw); err != nil {
		return err
	}
	type Plain OmitBoth
	var plain Plain
	if err := value.Decode(&plain); err != nil {
		return err
	}
	if plain.MyNull != nil {
		return fmt.Errorf("field %s: must be null", "myNull")
	}
	for i0 := range plain.MyNullArray {
		if plain.MyNullArray[i0] != nil {
			return fmt.Errorf("field %s: must be null", fmt.Sprintf("myNullArray[%d]", i0))
		}
	}
	*j = OmitBoth(plain)
	return nil
}
