validator

package
v1.2.2 Latest Latest
Warning

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

Go to latest
Published: Dec 5, 2024 License: MIT Imports: 9 Imported by: 0

Documentation

Index

Constants

View Source
const (
	ReasonNotAllow = iota + 1
	ReasonRejected
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Check

type Check struct {
	Folder      string   `yaml:"folder"`
	Subpackages bool     `yaml:"subpackages"`
	Exclude     []string `yaml:"exclude"`
	Rules       []Rule   `yaml:"rules"`
}

func (Check) IsExcluded added in v1.2.0

func (chk Check) IsExcluded(path string) bool

func (Check) ValidateImports

func (chk Check) ValidateImports(path string, imports []*ast.ImportSpec, debug bool) []ValidationError

type Config

type Config struct {
	Checks []Check `yaml:"imports-checks"`
}

type Reason

type Reason int

type Rule

type Rule struct {
	Prefix string   `yaml:"prefix"`
	Reject []string `yaml:"reject"`
	Allow  []string `yaml:"allow"`
}

type ValidationError

type ValidationError struct {
	Path       string
	Check      Check
	Rule       Rule
	ImportPath string
	Reason     Reason
}

func Validate

func Validate(root string, checks []Check, debug bool) ([]ValidationError, error)

Jump to

Keyboard shortcuts

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