validate

package
v0.0.0 Latest Latest
Warning

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

Go to latest
Published: Apr 24, 2026 License: None detected not legal advice Imports: 0 Imported by: 0

Documentation

Overview

Package validate contains the code to validate SST data contained in a Stage.

Index

Constants

View Source
const (
	InfoLevel
	InfoEnterLevel
	InfoLeaveLevel
	WarnLevel
	ErrorLevel
)

Variables

View Source
var (
	ErrRDFTypeMissing = &tripleFormatterError{message: "rdf:type missing", format: "missing%*s%*s%*s rdf:type"}
	ErrDomainMismatch = &tripleFormatterError{message: "domain mismatch", format: "domain mismatch%*s%*s%*s"}
	ErrRangeMismatch  = &tripleFormatterError{message: "range mismatch", format: "range mismatch%*s%*s%*s"}
)

Functions

func DomainAndRange

func DomainAndRange(graph sst.NamedGraph, report *ValidateReport, log Logger) error

func ExperimentalNamedGraphForAcyclic

func ExperimentalNamedGraphForAcyclic(graph sst.NamedGraph, log Logger) error

func ExperimentalNamedGraphForConnectedGraph

func ExperimentalNamedGraphForConnectedGraph(graph sst.NamedGraph, log Logger) error

func ExperimentalNamedGraphForTypeDefinitions

func ExperimentalNamedGraphForTypeDefinitions(graph sst.NamedGraph, log Logger) error

func ExtractShapes

func ExtractShapes(stShapes sst.Stage) (shapes *shapesStruct)

Extract the Node and Property Shapes and return them as new allocated shapesStruct

func FunctionalProperty

func FunctionalProperty(graph sst.NamedGraph, report *ValidateReport, log Logger) error

func PrintShapes

func PrintShapes(shapes *shapesStruct)

func RdfType

func RdfType(graph sst.NamedGraph, report *ValidateReport, log Logger) error

func Run

func Run(arguments []string) error

func ValidateStage

func ValidateStage(st sst.Stage) (ngResult sst.NamedGraph)

Types

type CheckedSummary

type CheckedSummary struct {
	Triples    int `json:"triples"`
	Subjects   int `json:"subjects"`
	Properties int `json:"properties"`
}

type ExitStatusError

type ExitStatusError int

func (ExitStatusError) Error

func (e ExitStatusError) Error() string

func (ExitStatusError) Status

func (e ExitStatusError) Status() int

type Finding

type Finding struct {
	Kind    ValidationKind `json:"kind"`
	Rule    Rule           `json:"rule"`
	Level   string         `json:"level"` // "error" or "warning"
	Message string         `json:"message"`

	// related triple
	S string `json:"subject"`
	P string `json:"predicate"`
	O string `json:"object"`

	Expect string `json:"expect,omitempty"` // "range in {sso:Occurrence | sso:Terminal}"
	Actual string `json:"actual,omitempty"` // "object is literal xsd:string"
}

single finding

type LogLevel

type LogLevel int

type LogTarget

type LogTarget interface {
	// contains filtered or unexported methods
}

type Logger

type Logger interface {
	Log(level LogLevel, t sst.IBNode, v ...any) error
	LogForGraph(level LogLevel, t sst.NamedGraph, v ...any) error
	Logf(level LogLevel, t sst.IBNode, format string, v ...any) error
	LogfForGraph(level LogLevel, t sst.NamedGraph, format string, v ...any) error
}

type Rule

type Rule string
const (
	RuleRdfTypeMissing Rule = "RdfType_missing"
	RuleRdfTypeWrong   Rule = "RdfType_wrong"

	RuleDomainMismatch       Rule = "domain_mismatch"
	RuleRangeMismatch        Rule = "range_mismatch"
	RulePredicateNotProperty Rule = "predicate_not_property"
	RulePredicateNotKnown    Rule = "predicate_not_known"

	RulePredicateFunctionalProperty        Rule = "predicate_is_functional_property"
	RulePredicateInverseFunctionalProperty Rule = "predicate_is_inverse_functional_property"
)

type TripleStringFormatter

type TripleStringFormatter interface {
	FormatTripleString(s, p, o string) string
}

type ValidateReport

type ValidateReport struct {
	Kinds     []ValidationKind     `json:"kinds"`
	Passed    bool                 `json:"passed"`   // if there is any error, then false
	Findings  map[string][]Finding `json:"findings"` // warnings and errors
	Generated time.Time            `json:"generated"`
}

func NewReport

func NewReport(kinds ...ValidationKind) ValidateReport

func Validate

func Validate(stage sst.Stage, kinds ...ValidationKind) (*ValidateReport, error)

Validate runs the specified validation kinds on the given stage and returns a report.

func (*ValidateReport) Error

func (r *ValidateReport) Error(ngIRI string, f Finding)

func (*ValidateReport) FormatHumanReadable

func (r *ValidateReport) FormatHumanReadable() string

FormatHumanReadable returns a human-readable formatted validation report

func (*ValidateReport) FormatSummary

func (r *ValidateReport) FormatSummary() string

FormatSummary returns a concise, single-line summary for each finding.

func (*ValidateReport) String

func (r *ValidateReport) String() string

func (*ValidateReport) Warn

func (r *ValidateReport) Warn(ngIRI string, f Finding)

type ValidationKind

type ValidationKind string
const (
	KindRdfType            ValidationKind = "rdf_type"
	KindDomainRange        ValidationKind = "domain_range"
	KindFunctionalProperty ValidationKind = "functional_property"
)

type ValidationName

type ValidationName string

type Values

type Values[E ValuesEnum] struct {
	// contains filtered or unexported fields
}

func ValuesOf

func ValuesOf[E ValuesEnum](defaultKey string, otherKeys ...string) Values[E]

func (*Values[E]) Enums

func (v *Values[E]) Enums() []E

func (Values[E]) Help

func (v Values[E]) Help(h string) string

func (*Values[E]) Keys

func (v *Values[E]) Keys() []string

func (*Values[E]) Len

func (v *Values[E]) Len() int

func (*Values[E]) Set

func (v *Values[E]) Set(s string) error

func (Values[E]) String

func (v Values[E]) String() string

func (Values[E]) Type

func (v Values[E]) Type() string

type ValuesEnum

type ValuesEnum interface {
	~int | ~uint | ~int8 | ~uint8 | ~int32 | ~uint16 | ~int16 | ~uint32 | ~int64 | ~uint64
}

Jump to

Keyboard shortcuts

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