Documentation
¶
Index ¶
Constants ¶
View Source
const ValidatorVersion = "contracts-validator/v0.1.1"
Variables ¶
View Source
var ( ErrInvalidRoot = errors.New("contracts: invalid schema root") ErrNotFound = errors.New("contracts: schema not found") ErrPathEscape = errors.New("contracts: path escapes root") ErrTooManyFiles = errors.New("contracts: too many schema files") ErrFileTooLarge = errors.New("contracts: schema too large") ErrInvalidJSON = errors.New("contracts: invalid json") ErrNotJSONObject = errors.New("contracts: schema must be a JSON object") ErrRefNotAllowed = errors.New("contracts: $ref not allowed") ErrRefTooDeep = errors.New("contracts: $ref depth exceeded") ErrTooManyRefs = errors.New("contracts: too many $ref resolutions") ErrRefPointerInvalid = errors.New("contracts: invalid json pointer") ErrCanonicalTooLarge = errors.New("contracts: canonical json exceeds max bytes") ErrCompiledTooLarge = errors.New("contracts: compiled schema exceeds max nodes") )
Functions ¶
This section is empty.
Types ¶
type CompiledSchema ¶
type CompiledSchema struct {
RootPath string `json:"root_path"`
LoadedDocs []LoadedDocDigest `json:"loaded_docs"` // all schema files referenced (sorted)
HashSHA256 string `json:"hash_sha256"` // hash of CanonicalJSON
CanonicalJSON []byte `json:"canonical_json"` // deterministic JSON bytes
JSON map[string]any `json:"json"` // compiled tree
}
CompiledSchema is a fully inlined schema with all local $ref resolved (bounded).
type LoadedDocDigest ¶
type Report ¶
type Report struct {
GeneratedAt time.Time `json:"generated_at"`
ValidatorVersion string `json:"validator_version"`
SchemaRootPath string `json:"schema_root_path,omitempty"`
SchemaHash string `json:"schema_hash,omitempty"`
CheckedNodes int `json:"checked_nodes"`
Errors int `json:"errors"`
Warnings int `json:"warnings"`
Infos int `json:"infos"`
Violations []Violation `json:"violations"`
}
type SchemaDoc ¶
type SchemaDoc struct {
Path string `json:"path"` // normalized rel path (slashes)
LoadedAt time.Time `json:"loaded_at"` // UTC
SHA256 string `json:"sha256"` // hash of raw bytes
JSON map[string]any `json:"json"` // parsed JSON object
}
SchemaDoc is a raw loaded schema document.
type Store ¶
type Store struct {
// contains filtered or unexported fields
}
func (*Store) Compile ¶
Compile loads a root schema and resolves all local $ref into a single inlined schema (bounded).
type StoreOptions ¶
type StoreOptions struct {
MaxFiles int // default 5000
MaxFileBytes int64 // default 2 MiB per schema
MaxRefDepth int // default 64
MaxRefs int // default 20000 (total resolved refs)
MaxCanonicalBytes int64 // default 4 MiB compiled canonical JSON
MaxCompiledNodes int // default 500000 nodes emitted during compilation
}
type VOptions ¶
type VOptions struct {
MaxDepth int `json:"max_depth"` // default 64
MaxNodes int `json:"max_nodes"` // default 250000
MaxIssues int `json:"max_issues"` // default 10000
MaxRegexCache int `json:"max_regex_cache"` // default 128
// big.Float precision for numeric comparisons (enum/const, min/max, etc.)
NumberPrecision uint `json:"number_precision"` // default 512
// If true, stop after first error.
FailFast bool `json:"fail_fast"`
// If true, warn when ignored keywords are present (format, $comment, title, description, etc.)
WarnIgnoredKeywords bool `json:"warn_ignored_keywords"`
}
type Validator ¶
type Validator struct {
// contains filtered or unexported fields
}
func NewValidator ¶
Click to show internal directories.
Click to hide internal directories.