Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type BCP47Validator ¶
type BCP47Validator struct {
// contains filtered or unexported fields
}
BCP47Validator generates code that will verify if a field is a BCP47 compatible string https://tools.ietf.org/html/bcp47
func NewBCP47Validator ¶
func NewBCP47Validator() *BCP47Validator
NewBCP47Validator holds the BCP47Validator state
func (*BCP47Validator) Generate ¶
func (s *BCP47Validator) Generate(sType reflect.Type, fieldStruct reflect.StructField, params []string) (string, error)
Generate generates validation code
func (*BCP47Validator) Name ¶
func (s *BCP47Validator) Name() string
Name provides access to the name field
type Generater ¶
type Generater interface { Generate(reflect.Type, reflect.StructField, []string) (string, error) Name() string }
Generater defines the behavior of types that generate validation code
type HexValidator ¶
type HexValidator struct {
// contains filtered or unexported fields
}
HexValidator generates code that will verify if a field is a hex string 0x prefix is optional
func NewHexValidator ¶
func NewHexValidator() *HexValidator
NewHexValidator holds the HexValidator state
func (*HexValidator) Generate ¶
func (s *HexValidator) Generate(sType reflect.Type, fieldStruct reflect.StructField, params []string) (string, error)
Generate generates validation code
func (*HexValidator) Name ¶
func (s *HexValidator) Name() string
Name provides access to the name field
type LengthValidateGen ¶
type LengthValidateGen struct {
// contains filtered or unexported fields
}
LengthValidateGen generates code that will verify the exact length of a String or String Pointer field. Slice and Array support coming later. It will flag nil string pointers as valid, use in conjunction with NotNil validator if you don't want nil values
func NewLengthValidator ¶
func NewLengthValidator() *LengthValidateGen
NewLengthValidator holds LengthValidator state
func (*LengthValidateGen) Generate ¶
func (s *LengthValidateGen) Generate(sType reflect.Type, fieldStruct reflect.StructField, params []string) (string, error)
Generate generates validation code
func (*LengthValidateGen) Name ¶
func (s *LengthValidateGen) Name() string
Name provides access to the name field
type NotNilValidator ¶
type NotNilValidator struct {
// contains filtered or unexported fields
}
NotNilValidator generates code that will verify if a pointer is nil Slice and Array support coming later. It will flag nil string pointers as valid, use in conjunction with NotNil validator if you don't want nil values
func NewNotNilValidator ¶
func NewNotNilValidator() *NotNilValidator
NewNotNilValidator holds the NotNilValidator state
func (*NotNilValidator) Generate ¶
func (s *NotNilValidator) Generate(sType reflect.Type, fieldStruct reflect.StructField, params []string) (string, error)
Generate generates validation code
func (*NotNilValidator) Name ¶
func (s *NotNilValidator) Name() string
Name provides access to the name field
type UUIDValidator ¶
type UUIDValidator struct {
// contains filtered or unexported fields
}
UUIDValidator generates code that will verify if a field is a UUID string
func NewUUIDValidator ¶
func NewUUIDValidator() *UUIDValidator
NewUUIDValidator holds the UUIDValidator state
func (*UUIDValidator) Generate ¶
func (s *UUIDValidator) Generate(sType reflect.Type, fieldStruct reflect.StructField, params []string) (string, error)
Generate generates validation code
func (*UUIDValidator) Name ¶
func (s *UUIDValidator) Name() string
Name provides access to the name field
type ValidateGenerator ¶
ValidateGenerator holds a map of identifiers and Generater's
func NewValidateGenerator ¶
func NewValidateGenerator() *ValidateGenerator
NewValidateGenerator creates a new pointer value of type ValidateGernerator - Hex: checks if a string is a valid hexadecimal format number - Length: takes 1 integer argument and compares the length of a string field against that - NotNil: Validate fails if field is nil - UUID: Checks and fails if a string is not a valid UUID
func (*ValidateGenerator) AddValidation ¶
func (s *ValidateGenerator) AddValidation(g Generater) error
AddValidation adds a Validation to a ValidateGenerator, that Validation can be applied to a struct field using the string returned by validater.Name()
func (*ValidateGenerator) Generate ¶
func (s *ValidateGenerator) Generate(out io.Writer, i interface{}) error
Generate generates Validate method for a structure Implicitly generates code that validates Structs, Slices and Maps which can be nested. Null pointer fields are considered valid by default Return value of generated function is an ErrorMap of ErrorArrays, where each element of an ErrorArray represents a failed validation
type ValidationCommand ¶
type ValidationCommand struct { Params []string // contains filtered or unexported fields }
ValidationCommand holds the ValidationCommand state
func NewValidationCommand ¶
func NewValidationCommand(n string) ValidationCommand
NewValidationCommand creates a new value of type ValidationCommand
func ParseTag ¶
func ParseTag(interf interface{}, tag string) ([]ValidationCommand, error)
ParseTag parses given struct tags
func (*ValidationCommand) Name ¶
func (s *ValidationCommand) Name() string
Name provides access to the name field