validationfile

package
v1.56.2 Latest Latest
Warning

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

Go to latest
Published: Sep 11, 2026 License: Apache-2.0 Imports: 25 Imported by: 1

Documentation

Overview

Package validationfile contains code to manipulate files accepted by the `zed validate` CLI.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CompileSchema added in v1.43.0

func CompileSchema(schema compiler.InputSchema, cts *caveattypes.TypeSet) (*compiler.CompiledSchema, error)

CompileSchema takes an InputSchema and returns the compiled schema, or else an error. TODO: this is probably the wrong place for this, in part because it's coupling to the compiler implementation.

func ParseAssertionsBlock

func ParseAssertionsBlock(contents []byte) (*blocks.Assertions, error)

ParseAssertionsBlock parses the given contents as an assertions block.

func ParseExpectedRelationsBlock added in v1.5.0

func ParseExpectedRelationsBlock(contents []byte) (*blocks.ParsedExpectedRelations, error)

ParseExpectedRelationsBlock parses the given contents as an expected relations block.

Types

type PopulatedValidationFile added in v1.5.0

type PopulatedValidationFile struct {
	// Schema is the entered schema text, if any.
	Schema string

	// NamespaceDefinitions are the namespaces defined in the validation file, in either
	// direct or compiled from schema form.
	NamespaceDefinitions []*core.NamespaceDefinition

	// CaveatDefinitions are the caveats defined in the validation file, in either
	// direct or compiled from schema form.
	CaveatDefinitions []*core.CaveatDefinition

	// Relationships are the relationships defined in the validation file, either directly
	// or in the relationships block.
	Relationships []tuple.Relationship

	// ParsedFiles are the underlying parsed validation files.
	ParsedFiles []ValidationFile
}

PopulatedValidationFile contains the fully parsed information from a validation file.

func PopulateFromFS added in v1.56.1

func PopulateFromFS(ctx context.Context, dl datalayer.DataLayer, caveatTypeSet *caveattypes.TypeSet, fsys fs.FS, filePath string) (*PopulatedValidationFile, datastore.Revision, error)

PopulateFromFS populates the given datastore with the namespaces and tuples found in the validation file read from fsys.

It is the counterpart of PopulateFromFiles for files that are not on disk, such as those embedded into the binary with //go:embed. Any schemaFile the validation file references is resolved against the same filesystem.

func PopulateFromFiles

func PopulateFromFiles(ctx context.Context, dl datalayer.DataLayer, caveatTypeSet *caveattypes.TypeSet, filePaths []string) (*PopulatedValidationFile, datastore.Revision, error)

PopulateFromFiles populates the given datastore with the namespaces and tuples found in the validation file(s) specified.

func PopulateFromFilesContents added in v1.11.0

func PopulateFromFilesContents(ctx context.Context, dl datalayer.DataLayer, caveatTypeSet *caveattypes.TypeSet, filesContents map[string][]byte) (*PopulatedValidationFile, datastore.Revision, error)

PopulateFromFilesContents populates the given datastore with the namespaces and tuples found in the validation file(s) contents specified.

type ValidationFile

type ValidationFile struct {
	// Schema is the schema.
	Schema blocks.SchemaWithPosition `yaml:"schema"`

	// Relationships are the relationships specified in the validation file.
	Relationships blocks.ParsedRelationships `yaml:"relationships"`

	// Assertions are the assertions defined in the validation file. May be nil
	// if no assertions are defined.
	Assertions blocks.Assertions `yaml:"assertions"`

	// ExpectedRelations is the map of expected relations.
	ExpectedRelations blocks.ParsedExpectedRelations `yaml:"validation"`

	// NamespaceConfigs are the namespace configuration protos, in text format.
	//
	// Deprecated: only for internal use. Use `schema`.
	NamespaceConfigs []string `yaml:"namespace_configs"`

	// ValidationTuples are the validation tuples, in tuple string syntax.
	//
	// Deprecated: only for internal use. Use `relationships`.
	ValidationTuples []string `yaml:"validation_tuples"`

	// Schema file represents the path specified for the schema file
	SchemaFile string `yaml:"schemaFile"`
}

ValidationFile is a structural representation of the validation file format.

func DecodeValidationFile added in v1.5.0

func DecodeValidationFile(contents []byte) (*ValidationFile, error)

DecodeValidationFile decodes the validation file as found in the contents bytes and returns it.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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