spec

package
v0.24.4-beta Latest Latest
Warning

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

Go to latest
Published: Nov 30, 2023 License: MIT Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type CheckWithLocation

type CheckWithLocation struct {
	Check    string                `json:"check"`    // Name of the check
	Location parsers.TokenLocation `json:"location"` // Location of the check
}

type FieldSpec

type FieldSpec struct {
	Field    *parsers.NodeKey    `json:"field"`    // Field to check
	Type     string              `json:"type"`     // Type of the field
	Optional bool                `json:"optional"` // Whether the field is optional
	Default  string              `json:"default"`  // Default value of the field
	Notes    string              `json:"notes"`    // Notes about the rule
	Checks   []CheckWithLocation `json:"checks"`   // List of checks to perform

	FieldLocation    parsers.TokenLocation `json:"field_location"`    // Location of the field
	TypeLocation     parsers.TokenLocation `json:"type_location"`     // Location of the type
	OptionalLocation parsers.TokenLocation `json:"optional_location"` // Location of the optional field
	DefaultLocation  parsers.TokenLocation `json:"default_location"`  // Location of the default field
	NotesLocation    parsers.TokenLocation `json:"notes_location"`    // Location of the notes field
}

type ObjectDef

type ObjectDef struct {
	Name       string              `json:"name"`       // Name of the object
	Properties []ObjectPropertyDef `json:"properties"` // List of properties of the object

	NameLocation parsers.TokenLocation `json:"name_location"` // Location of the name
}

type ObjectPropertyDef

type ObjectPropertyDef struct {
	Name     string `json:"name"`     // Name of the property
	Type     string `json:"type"`     // Type of the property
	Optional bool   `json:"optional"` // Whether the property is optional

	NameLocation     parsers.TokenLocation `json:"name_location"`     // Location of the name
	TypeLocation     parsers.TokenLocation `json:"type_location"`     // Location of the type
	OptionalLocation parsers.TokenLocation `json:"optional_location"` // Location of the optional field
}

type SpecParser

type SpecParser interface {
	Parse(spec []byte) (*Specification, []SpecParserError)
}

func NewSpecParser

func NewSpecParser() SpecParser

type SpecParserError

type SpecParserError struct {
	ErrorMessage string
	Location     parsers.TokenLocation
}

type Specification

type Specification struct {
	File       string            `json:"file"`        // File this specification is for
	FileFormat string            `json:"file_format"` // Format of the file
	Imports    map[string]string `json:"imports"`     // Imported rulebooks with their aliases
	Fields     []FieldSpec       `json:"fields"`      // Node that holds the specification of the file
	Objects    []ObjectDef       `json:"objects"`     // List of object definitions

	FileLocation         parsers.TokenLocation            `json:"file_location"`          // Location of the file specification
	FileFormatLocation   parsers.TokenLocation            `json:"file_format_location"`   // Location of the file format
	ImportsAliasLocation map[string]parsers.TokenLocation `json:"imports_alias_location"` // Location of the imports alias
	ImportsLocation      map[string]parsers.TokenLocation `json:"imports_location"`       // Location of the imports field
}

Jump to

Keyboard shortcuts

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