generator

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Jan 14, 2024 License: MIT Imports: 18 Imported by: 0

Documentation

Index

Constants

View Source
const AssetDebug = false

AssetDebug is true if the assets were built with the debug flag enabled.

View Source
const OZZO_VALIDATOR_TEMPLATE string = "templates/ozzo-validator.tmpl"
View Source
const OZZO_VALIDATOR_TEST_TEMPLATE string = "templates/ozzo-validator-test.tmpl"

Variables

This section is empty.

Functions

func Asset

func Asset(name string) ([]byte, error)

Asset loads and returns the asset for the given name. It returns an error if the asset could not be found or could not be loaded.

func AssetDigest

func AssetDigest(name string) ([sha256.Size]byte, error)

AssetDigest returns the digest of the file with the given name. It returns an error if the asset could not be found or the digest could not be loaded.

func AssetDir

func AssetDir(name string) ([]string, error)

AssetDir returns the file names below a certain directory embedded in the file by go-bindata. For example if you run go-bindata on data/... and data contains the following hierarchy:

data/
  foo.txt
  img/
    a.png
    b.png

then AssetDir("data") would return []string{"foo.txt", "img"}, AssetDir("data/img") would return []string{"a.png", "b.png"}, AssetDir("foo.txt") and AssetDir("notexist") would return an error, and AssetDir("") will return []string{"data"}.

func AssetInfo

func AssetInfo(name string) (os.FileInfo, error)

AssetInfo loads and returns the asset info for the given name. It returns an error if the asset could not be found or could not be loaded.

func AssetNames

func AssetNames() []string

AssetNames returns the names of the assets.

func AssetString

func AssetString(name string) (string, error)

AssetString returns the asset contents as a string (instead of a []byte).

func Digests

func Digests() (map[string][sha256.Size]byte, error)

Digests returns a map of all known files and their checksums.

func MustAsset

func MustAsset(name string) []byte

MustAsset is like Asset but panics when Asset would return an error. It simplifies safe initialization of global variables.

func MustAssetString

func MustAssetString(name string) string

MustAssetString is like AssetString but panics when Asset would return an error. It simplifies safe initialization of global variables.

func RestoreAsset

func RestoreAsset(dir, name string) error

RestoreAsset restores an asset under the given directory.

func RestoreAssets

func RestoreAssets(dir, name string) error

RestoreAssets restores an asset under the given directory recursively.

Types

type TestData

type TestData struct {
	Testing bool
	Valid   map[string]TypedList
	Invalid map[string]TypedList
}

type TypedList

type TypedList struct {
	Int    []int
	Float  []float32
	String []string
}

type ValidateIsRule

type ValidateIsRule struct {
	Email            bool
	EmailFormat      bool
	URL              bool
	RequestURL       bool
	RequestURI       bool
	Alpha            bool
	Digit            bool
	Alphanumeric     bool
	UTFLetter        bool
	UTFDigit         bool
	UTFLetterNumeric bool
	UTFNumeric       bool
	LowerCase        bool
	UpperCase        bool
	Hexadecimal      bool
	HexColor         bool
	RGBColor         bool
	Int              bool
	Float            bool
	UUIDv3           bool
	UUIDv4           bool
	UUIDv5           bool
	UUID             bool
	CreditCard       bool
	ISBN10           bool
	ISBN13           bool
	ISBN             bool
	JSON             bool
	ASCII            bool
	PrintableASCII   bool
	Multibyte        bool
	FullWidth        bool
	HalfWidth        bool
	VariableWidth    bool
	Base64           bool
	DataURI          bool
	E164             bool
	CountryCode2     bool
	CountryCode3     bool
	DialString       bool
	MAC              bool
	IP               bool
	IPv4             bool
	IPv6             bool
	Subdomain        bool
	Domain           bool
	DNSName          bool
	Host             bool
	Port             bool
	MongoID          bool
	Latitude         bool
	Longitude        bool
	SSN              bool
	Semver           bool
}

type ValidateProject

type ValidateProject struct {
	Type         string
	MethodName   string
	Template     string
	TemplateTest string
	ForTest      bool
	Validators   map[string]ValidateStruct
}

Project information to generate validators. Generated from Validator Toml

func ParseToml

func ParseToml(tomlPath string) (*ValidateProject, error)

ParseToml parses the Toml file and generate ValidatorProject

func (*ValidateProject) Generate

func (vp *ValidateProject) Generate() error

Generate validators defined in ValidatorProject.Validators in the specified directory

func (*ValidateProject) GenerateWithTemplate

func (vp *ValidateProject) GenerateWithTemplate(template_path string) error

func (ValidateProject) Validate

func (vp ValidateProject) Validate() error

type ValidateProperty

type ValidateProperty struct {
	Name string
	Type string
	ValidateRule
}

Validator settings to apply to a field

func (ValidateProperty) Validate

func (vp ValidateProperty) Validate() error

type ValidateRule

type ValidateRule struct {
	In            TypedList
	NotIn         TypedList
	Length        []int
	RuneLength    []int
	Match         string
	Date          string
	Required      bool
	NotNil        bool
	Nil           bool
	NilOrNotEmpty bool
	Empty         bool
	MultipleOf    []TypedList
	Each          []ValidateRule
	//	When TODO
	Else []ValidateRule
	ValidateIsRule
}

type ValidateStruct

type ValidateStruct struct {
	Package    string
	Name       string
	Receiver   string
	Dir        string
	FileName   string
	FileMode   int
	Import     []string
	MethodName string
	Properties map[string]ValidateProperty
	TestData   TestData
}

Information on the struct that generates the validator and the validator go codes

func (ValidateStruct) Validate

func (vs ValidateStruct) Validate() error

Jump to

Keyboard shortcuts

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