Documentation
¶
Overview ¶
Package validator provides a common interface for algorithm-specific parameters.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ValidateConfig ¶
ValidateConfig validates the configuration without any algorithm-specific parameters. It returns a validated and potentially default-filled configuration.
Types ¶
type Parameters ¶
type Parameters interface {
// Validate checks if the parameters are valid within the context of the given configuration.
Validate(cfg *types.Config) error
// FromMap populates the parameter struct from a map of key-value strings.
// IMPORTANT: This method must have a pointer receiver to ensure that the calling
// struct is modified. This also ensures that only pointer types satisfy this interface.
FromMap(params map[string]string) error
// ToMap converts the parameter struct back into a map of key-value strings.
ToMap() map[string]string
// String returns a string representation of the parameters.
String() string
// IsNil checks if the underlying pointer is nil. This method must also have
// a pointer receiver to be invoked on a nil receiver without panicking.
IsNil() bool
}
Parameters defines the interface for algorithm-specific parameter validation and handling. This interface needs to be implemented by parameter structs for different hashing algorithms.
type ValidateFunc ¶
type Validated ¶
type Validated[T Parameters] struct { // Params holds the validated and populated algorithm-specific parameters. // It will be the zero value of its type (e.g., nil) if the input was nil. Params T // Config holds the validated and potentially default-filled configuration. Config *types.Config }
Validated holds the results of a successful validation operation on parameters.
func ValidateParams ¶
func ValidateParams[T Parameters](cfg *types.Config, p T) (*Validated[T], error)
ValidateParams decodes the parameter string from the configuration, populates the provided parameters object, and then runs the algorithm-specific validation. It returns a Validated struct containing the final parameters and configuration. The provided parameter 'p' must be a pointer to a struct that implements the Parameters interface. Use ValidateConfig for parameter-less validation.