Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ValidateYAML ¶
ValidateYAML performs all YAML validations: extension, existence, content, and structure. It returns an error if any of the validations fail.
Example usage:
var config Config
err := ValidateYAML("config.yaml", &config)
if err != nil {
log.Fatal(err)
}
func ValidateYAMLExists ¶
ValidateYAMLExists checks if the given YAML file exists. It returns true if the file exists, otherwise false.
Example usage:
exists := ValidateYAMLExists("config.yaml")
fmt.Println(exists) // Output: true
func ValidateYAMLExtension ¶
ValidateYAMLExtension checks if the given file has a .yaml or .yml extension. It returns true if the file has a valid YAML extension, otherwise false.
Example usage:
valid := ValidateYAMLExtension("config.yaml")
fmt.Println(valid) // Output: true
func ValidateYAMLHasContent ¶
ValidateYAMLHasContent checks if the given YAML file is not empty. It returns a boolean indicating whether the file has content and an error if any occurred during reading the file.
Example usage:
hasContent, err := ValidateYAMLHasContent("config.yaml")
if err != nil {
log.Fatal(err)
}
fmt.Println(hasContent) // Output: true
func ValidateYAMLStructure ¶
ValidateYAMLStructure checks if the given YAML file can be properly unmarshaled into the provided struct. It returns an error if the file cannot be read or if the content cannot be unmarshaled into the provided struct.
Example usage:
var config Config
err := ValidateYAMLStructure("config.yaml", &config)
if err != nil {
log.Fatal(err)
}
Types ¶
This section is empty.