types/publish_request.go
func (p *PublishRequest) Validate() error {
	p.Args = []string{}

	if len(p.PactURLs) != 0 {
		p.Args = append(p.Args, p.PactURLs...)
	} else {
		return fmt.Errorf("'PactURLs' is mandatory")
	}

	if p.BrokerUsername != "" {
		p.Args = append(p.Args, "--broker-username", p.BrokerUsername)
	}

	if p.BrokerPassword != "" {
		p.Args = append(p.Args, "--broker-password", p.BrokerPassword)
	}

	if p.PactBroker != "" && ((p.BrokerUsername == "" && p.BrokerPassword != "") || (p.BrokerUsername != "" && p.BrokerPassword == "")) {
		return errors.New("both 'BrokerUsername' and 'BrokerPassword' must be supplied if one given")
	}

	if p.PactBroker == "" {
		return fmt.Errorf("'PactBroker' is mandatory")
	}
	p.Args = append(p.Args, "--broker-base-url", p.PactBroker)

	if p.BrokerToken != "" {
		p.Args = append(p.Args, "--broker-token", p.BrokerToken)
	}

	if p.ConsumerVersion == "" {
		return fmt.Errorf("'ConsumerVersion' is mandatory")
	}
	p.Args = append(p.Args, "--consumer-app-version", p.ConsumerVersion)

	if len(p.Tags) > 0 {
		for _, t := range p.Tags {
			p.Args = append(p.Args, "--tag", t)
		}
	}

	if p.Verbose {
		p.Args = append(p.Args, "--verbose")
	}

	return nil
}
func (p *PublishRequest) Validate() error {
	p.Args = []string{}

	if len(p.PactURLs) != 0 {
		p.Args = append(p.Args, p.PactURLs...)
	} else {
		return fmt.Errorf("'PactURLs' is mandatory")
	}

	if p.BrokerUsername != "" {
		p.Args = append(p.Args, "--broker-username", p.BrokerUsername)
	}

	if p.BrokerPassword != "" {
		p.Args = append(p.Args, "--broker-password", p.BrokerPassword)
	}

	if p.PactBroker != "" && ((p.BrokerUsername == "" && p.BrokerPassword != "") || (p.BrokerUsername != "" && p.BrokerPassword == "")) {
		return errors.New("both 'BrokerUsername' and 'BrokerPassword' must be supplied if one given")
	}

	if p.PactBroker == "" {
		return fmt.Errorf("'PactBroker' is mandatory")
	}
	p.Args = append(p.Args, "--broker-base-url", p.PactBroker)

	if p.BrokerToken != "" {
		p.Args = append(p.Args, "--broker-token", p.BrokerToken)
	}

	if p.ConsumerVersion == "" {
		return fmt.Errorf("'ConsumerVersion' is mandatory")
	}
	p.Args = append(p.Args, "--consumer-app-version", p.ConsumerVersion)

	if len(p.Tags) > 0 {
		for _, t := range p.Tags {
			p.Args = append(p.Args, "--tag", t)
		}
	}

	if p.Verbose {
		p.Args = append(p.Args, "--verbose")
	}

	return nil
}
// Validate checks that the minimum fields are provided.
// Deprecated: This map be deleted after the native library replaces Ruby deps,
// and should not be used outside of this library.