// Code generated by mdatagen. DO NOT EDIT.

package samplepkg

import (
	"errors"
)

// PortNumber a port number to connect to.
type PortNumber int32

type SampleConfig struct {
	// The host name to connect to.
	HostName string `mapstructure:"host_name"`
	// The port to connect to.
	Port PortNumber `mapstructure:"port"`
	// prevent unkeyed literal initialization
	_ struct{}
}

// Validate validates the SampleConfig fields according to schema annotations.
func (c *SampleConfig) Validate() error {
	var err error

	if c.HostName == "" {
		err = errors.Join(err, errors.New("host_name is required"))
	}

	if len(c.HostName) < 1 {
		err = errors.Join(err, errors.New("host_name must have minimum length of 1"))
	}

	if c.Port < 1 {
		err = errors.Join(err, errors.New("port value must be greater than or equal to 1"))
	}
	if c.Port > 10000 {
		err = errors.Join(err, errors.New("port value must be less than or equal to 10000"))
	}

	return err
}

// NewDefaultSampleConfig returns a new SampleConfig with default values consistent with the annotations in the schema.
func NewDefaultSampleConfig() SampleConfig {
	return SampleConfig{
		HostName: "localhost",
		Port:     8080,
	}
}
