mirror of
https://github.com/hanzoai/telemetry.git
synced 2026-10-30 20:01:49 +00:00
<!--Ex. Fixing a bug - Describe the bug and how this fixes the issue. Ex. Adding a feature - Explain what this achieves.--> #### Description The `xconfmap.Validator` interface has existed in some form for a very long time now and is ready to be stabilized. Similarly, the `xconfmap.Validate` method has existed in it's current state for over a year and doesn't have any open issues I'm aware of. It should also be ready for stabilization. Many modules depend on `xconfmap` merely for the validation facilities (as can be seen by the go.mod diffs), so this will allow them to depend on only stable modules. --------- Co-authored-by: Alex Boten <[email protected]>
22 lines
800 B
Go
22 lines
800 B
Go
// Copyright The OpenTelemetry Authors
|
|
// SPDX-License-Identifier: Apache-2.0
|
|
|
|
package confmap // import "go.opentelemetry.io/collector/confmap"
|
|
|
|
import (
|
|
"go.opentelemetry.io/collector/confmap/internal"
|
|
)
|
|
|
|
// Validator defines an optional interface for configuration structs to
|
|
// implement to check for validity before Collector startup.
|
|
type Validator = internal.Validator
|
|
|
|
// Validate validates a config struct by recursively checking if it or any of
|
|
// its fields implement the Validator interface and performing validation
|
|
// on each one that does. A struct failing validation will not cause
|
|
// validation to stop; all structs will be validated, and all errors
|
|
// will be returned with a single error created from [errors.Join].
|
|
func Validate(cfg any) error {
|
|
return internal.Validate(cfg)
|
|
}
|