validation

package
v0.2.1 Latest Latest
Warning

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

Go to latest
Published: Mar 4, 2026 License: MIT Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type ValidationResult

type ValidationResult struct {
	Errors   []contract.ValidationError
	Warnings []contract.ValidationWarning
}

ValidationResult aggregates errors and warnings from all validation layers.

func Validate

func Validate(c *contract.Contract, rawYAML []byte, bundleFS fs.FS) ValidationResult

Validate runs all three validation layers in order on the given contract. If structural validation fails, subsequent layers are skipped. The rawYAML parameter is the original YAML bytes for JSON Schema validation. The bundleFS parameter provides access to bundle files for cross-field validation.

func ValidateCrossField

func ValidateCrossField(c *contract.Contract, bundleFS fs.FS) ValidationResult

ValidateCrossField performs Layer 2 validation: cross-field consistency, file existence, reference validation, and semantic rules that cannot be expressed in JSON Schema alone.

func ValidateSemantic

func ValidateSemantic(c *contract.Contract) ValidationResult

ValidateSemantic performs Layer 3 validation: semantic consistency checks based on cross-concern rules that span multiple sections of the contract.

func ValidateStructural

func ValidateStructural(data interface{}) ValidationResult

ValidateStructural performs Layer 1 validation using JSON Schema. It takes the raw YAML bytes (converted to a generic interface{}) and validates against the embedded pacto v1.0 JSON Schema.

func (*ValidationResult) AddError

func (r *ValidationResult) AddError(path, code, message string)

AddError appends a validation error.

func (*ValidationResult) AddWarning

func (r *ValidationResult) AddWarning(path, code, message string)

AddWarning appends a validation warning.

func (*ValidationResult) IsValid

func (r *ValidationResult) IsValid() bool

IsValid returns true if there are no errors.

func (*ValidationResult) Merge

func (r *ValidationResult) Merge(other ValidationResult)

Merge combines another result into this one.

Jump to

Keyboard shortcuts

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