validator

package
v0.0.0-...-225f367 Latest Latest
Warning

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

Go to latest
Published: Oct 13, 2022 License: MIT Imports: 10 Imported by: 0

Documentation

Index

Constants

View Source
const BGRed = 41

BGRed red color of background

View Source
const FGRed = 31

FGRed red color of text

Variables

This section is empty.

Functions

func CountDigits

func CountDigits(i int) (count int)

CountDigits returns the number of digits in a decimal number

func ErrorDetails

func ErrorDetails(text string, errs []TemplateError) string

ErrorDetails constructs errors as a single string which shows where validation errors are happening.

func NewCommand

func NewCommand() *cli.Command

NewCommand creates a template validator.

func PrintErrorDetails

func PrintErrorDetails(text string, errs []TemplateError)

PrintErrorDetails prints error details

func SplitLines

func SplitLines(str string) []string

SplitLines splits a string into lines Supports windows or unix line segments

Types

type ErrorLevel

type ErrorLevel string

ErrorLevel is the type of error found

type TemplateError

type TemplateError struct {
	Line        int
	Char        int
	Description string
	Level       ErrorLevel
}

TemplateError describes the details of template error.

func CreateTemplateError

func CreateTemplateError(err error, level ErrorLevel) TemplateError

CreateTemplateError parse and return a template error.

func Exec

func Exec(t *textTemplate.Template, data interface{}, buf *bytes.Buffer) []TemplateError

Exec applies a parsed template to the specified data object

func Validate

func Validate(text string) (*textTemplate.Template, []TemplateError)

Validate validates a template

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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