validate

package
v0.7.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Sep 9, 2025 License: Apache-2.0 Imports: 5 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ValidateCmd = &cobra.Command{
	Use:   "validate",
	Short: "validate an oscal document",
	Long:  "Validate an OSCAL document against the OSCAL schema version specified in the document.",
	RunE: func(cmd *cobra.Command, args []string) error {

		validationResponse, err := validation.ValidationCommand(inputfile)

		if err != nil {
			return err
		}

		if validationResultFile != "" {
			err := validation.WriteValidationResult(validationResponse.Result, validationResultFile)
			if err != nil {
				log.Printf("Failed to write validation result to %s: %s\n", validationResultFile, err)
			}
		}

		for _, warning := range validationResponse.Warnings {
			log.Println(warning)
		}

		if validationResponse.JsonSchemaError != nil {
			jsonResult, err := json.MarshalIndent(validationResponse.Result, "", "  ")
			if err != nil {
				return fmt.Errorf("failed to format validation result as JSON: %v", err)
			}
			return fmt.Errorf("invalid OSCAL document, results: %s", string(jsonResult))
		}

		log.Printf("Successfully validated %s is valid OSCAL version %s %s\n", inputfile, validationResponse.Validator.GetSchemaVersion(), validationResponse.Validator.GetModelType())
		return nil
	},
}

Functions

This section is empty.

Types

This section is empty.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL