You are an expert in writing code in many different languages. Your goal is to perform code completion for the following code, keeping in mind the rest of the code and the file meta data.
    Metadata details:
    filename: ipamdata.go
    path of file: ./repos/docker-ce/components/engine/libnetwork/driverapi
    
    the code of the file until where you have to start completion: package driverapi

import (
	"encoding/json"
	"fmt"
	"net"

	"github.com/docker/docker/libnetwork/types"
)

// MarshalJSON encodes IPAMData into json message
func (i *IPAMData) MarshalJSON() ([]byte, error) {
	m := map[string]interface{}{}
	m["AddressSpace"] = i.AddressSpace
	if i.Pool != nil {
		m["Pool"] = i.Pool.String()
	}
	if i.Gateway != nil {
		m["Gateway"] = i.Gateway.String()
	}
	if i.AuxAddresses != nil {
		am := make(map[string]string, len(i.AuxAddresses))
		for k, v := range i.AuxAddresses {
			am[k] = v.String()
		}
		m["AuxAddresses"] = am
	}
	return json.Marshal(m)
}

// UnmarshalJSON decodes a json message into IPAMData
func (i *IPAMData) UnmarshalJSON(data []byte) error {
	var (
		m   map[string]interface{}
		err error
	)
	if err := json.Unmarshal(data, &m); err != nil {
		return err
	}
	i.Address
    
func (i *IPAMData) Validate() error {
	var isV6 bool
	if i.Pool == nil {
		return types.BadRequestErrorf("invalid pool")
	}
	if i.Gateway == nil {
		return types.BadRequestErrorf("invalid gateway address")
	}
	isV6 = i.IsV6()
	if isV6 && i.Gateway.IP.To4() != nil || !isV6 && i.Gateway.IP.To4() == nil {
		return types.BadRequestErrorf("incongruent ip versions for pool and gateway")
	}
	for k, sip := range i.AuxAddresses {
		if isV6 && sip.IP.To4() != nil || !isV6 && sip.IP.To4() == nil {
			return types.BadRequestErrorf("incongruent ip versions for pool and secondary ip address %s", k)
		}
	}
	if !i.Pool.Contains(i.Gateway.IP) {
		return types.BadRequestErrorf("invalid gateway address (%s) does not belong to the pool (%s)", i.Gateway, i.Pool)
	}
	for k, sip := range i.AuxAddresses {
		if !i.Pool.Contains(sip.IP) {
			return types.BadRequestErrorf("invalid secondary address %s (%s) does not belong to the pool (%s)", k, i.Gateway, i.Pool)
		}
	}
	return nil
}