formatcheck

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Feb 25, 2018 License: MIT Imports: 3 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var Max = Check{
	Name: "max",
	Callback: func(o *writerutil.LeveledOutput, name string, fa *accessor.FieldAccessor, val string) error {
		o.WithBlock(fmt.Sprintf("if %s.%s > %s", name, fa.Name(), val), func() {
			o.Printf("merr = multierror.Append(merr, errors.New(\"%s max\"))\n", fa.GuessJSONFieldName(fa.Name()))
		})
		return nil
	},
}

Max :

View Source
var MaxLength = Check{
	Name: "maxLength",
	Callback: func(o *writerutil.LeveledOutput, name string, fa *accessor.FieldAccessor, val string) error {
		o.WithBlock(fmt.Sprintf("if len(%s.%s) > %s", name, fa.Name(), val), func() {
			o.Printf("merr = multierror.Append(merr, errors.New(\"%s maxLength\"))\n", fa.GuessJSONFieldName(fa.Name()))
		})
		return nil
	},
}

MaxLength :

View Source
var Min = Check{
	Name: "min",
	Callback: func(o *writerutil.LeveledOutput, name string, fa *accessor.FieldAccessor, val string) error {
		o.WithBlock(fmt.Sprintf("if %s.%s < %s", name, fa.Name(), val), func() {
			o.Printf("merr = multierror.Append(merr, errors.New(\"%s min\"))\n", fa.GuessJSONFieldName(fa.Name()))
		})
		return nil
	},
}

Min :

View Source
var MinLength = Check{
	Name: "minLength",
	Callback: func(o *writerutil.LeveledOutput, name string, fa *accessor.FieldAccessor, val string) error {
		o.WithBlock(fmt.Sprintf("if len(%s.%s) < %s", name, fa.Name(), val), func() {
			o.Printf("merr = multierror.Append(merr, errors.New(\"%s minLength\"))\n", fa.GuessJSONFieldName(fa.Name()))
		})
		return nil
	},
}

MinLength :

Functions

This section is empty.

Types

type Check

type Check struct {
	Name     string
	Value    string
	Callback func(o *writerutil.LeveledOutput, name string, fa *accessor.FieldAccessor, val string) error
}

Check : todo: rename

type FormatCheckable

type FormatCheckable interface {
	FormatCheck() error
}

FormatCheckable :

Jump to

Keyboard shortcuts

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