Documentation
¶
Index ¶
- func WriteValidationResult(validationResult ValidationResult, outputFile string) (err error)
- type ValidationResponse
- type ValidationResult
- type ValidationResultMetadata
- type Validator
- func (v *Validator) GetDocumentPath() string
- func (v *Validator) GetJsonModel() map[string]interface{}
- func (v *Validator) GetModelType() string
- func (v *Validator) GetSchemaVersion() string
- func (v *Validator) GetValidationResult() (ValidationResult, error)
- func (v *Validator) IsLatestOscalVersion() (bool, error)
- func (v *Validator) SetDocumentPath(documentPath string)
- func (v *Validator) Validate() error
- type ValidatorError
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func WriteValidationResult ¶
func WriteValidationResult(validationResult ValidationResult, outputFile string) (err error)
WriteValidationResult writes a ValidationResult to a file
Types ¶
type ValidationResponse ¶
type ValidationResponse struct {
Validator Validator
Result ValidationResult
Warnings []string
}
func ValidationCommand ¶
func ValidationCommand(inputFile string) (validationResponse ValidationResponse, err error)
ValidationCommand validates an OSCAL document Returns a ValidationResponse and an error
type ValidationResult ¶
type ValidationResult struct {
Valid bool `json:"valid" yaml:"valid"`
TimeStamp time.Time `json:"timeStamp" yaml:"timeStamp"`
Errors []ValidatorError `json:"errors,omitempty" yaml:"errors,omitempty"`
Metadata ValidationResultMetadata `json:"metadata" yaml:"metadata"`
}
func NewValidationResult ¶
func NewValidationResult(validator *Validator, errors []ValidatorError) ValidationResult
NewValidationResult creates a new ValidationResult from a Validator and a slice of ValidatorErrors
type ValidationResultMetadata ¶
type ValidationResultMetadata struct {
DocumentPath string `json:"documentPath,omitempty" yaml:"documentPath,omitempty"`
DocumentType string `json:"documentType,omitempty" yaml:"documentType,omitempty"`
DocumentVersion string `json:"documentVersion,omitempty" yaml:"documentVersion,omitempty"`
SchemaVersion string `json:"schemaVersion,omitempty" yaml:"schemaVersion,omitempty"`
}
type Validator ¶
type Validator struct {
// contains filtered or unexported fields
}
func NewValidator ¶
func NewValidator(oscalDoc utils.InterfaceOrBytes) (validator Validator, err error)
NewValidator returns a validator with the models version of the schema.
func NewValidatorDesiredVersion ¶
func NewValidatorDesiredVersion(oscalDoc utils.InterfaceOrBytes, desiredVersion string) (validator Validator, err error)
NewValidatorDesiredVersion returns a validator with the desired version of the schema.
func (*Validator) GetDocumentPath ¶
GetDocumentPath returns the path of the document being validated.
func (*Validator) GetJsonModel ¶
GetJsonModel returns the model being validated.
func (*Validator) GetModelType ¶
GetModelType returns the type of the model being validated.
func (*Validator) GetSchemaVersion ¶
GetSchemaVersion returns the version of the schema used to validate the model.
func (*Validator) GetValidationResult ¶
func (v *Validator) GetValidationResult() (ValidationResult, error)
GetValidationResult returns a ValidationResult. If the validation has not been run, an error is returned.
func (*Validator) IsLatestOscalVersion ¶
IsLatestOscalVersion returns true if the model is the latest version of the OSCAL schema.
func (*Validator) SetDocumentPath ¶
SetDocumentPath sets the path of the document being validated.
type ValidatorError ¶
type ValidatorError struct {
KeywordLocation string `json:"keywordLocation" yaml:"keywordLocation"`
AbsoluteKeywordLocation string `json:"absoluteKeywordLocation" yaml:"absoluteKeywordLocation"`
InstanceLocation string `json:"instanceLocation" yaml:"instanceLocation"`
Error string `json:"error" yaml:"error"`
FailedValue interface{} `json:"failedValue,omitempty" yaml:"failedValue,omitempty"`
}
Extension of the jsonschema.BasicError struct to include the failed value if the failed value is a map or slice, it will be omitted
func ExtractErrors ¶
func ExtractErrors(originalObject map[string]interface{}, validationError jsonschema.Basic) (validationErrors []ValidatorError)
Creates a []ValidatorError from a jsonschema.Basic The jsonschema.Basic contains the errors from the validation