validation

package module
v0.0.0-...-692a30e Latest Latest
Warning

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

Go to latest
Published: Feb 24, 2023 License: MIT Imports: 2 Imported by: 2

README

This package is a simple wrapper for validator.

Installation

go get -u github.com/znbang/validation

Example

package main

import (
	"fmt"

	"github.com/znbang/validation"
)

func main() {
	title := ""
	url := "://github.com/znbang/validation"
	validate := validation.New()
	validate.Required(title, "title", "Please input the title.")
	validate.URL(url, "url", "Invalid URL.")
	for k, v := range validate.Errors {
		fmt.Println("Field:", k, ", Message:", v)
	}
}

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Validation

type Validation struct {
	Errors map[string]string
	// contains filtered or unexported fields
}

func New

func New() *Validation

func (*Validation) ASCII

func (v *Validation) ASCII(field interface{}, key string, message string) bool

func (*Validation) Email

func (v *Validation) Email(field interface{}, key string, message string) bool

func (*Validation) HasErrors

func (v *Validation) HasErrors() bool

func (*Validation) Latitude

func (v *Validation) Latitude(field interface{}, key string, message string) bool

func (*Validation) Longitude

func (v *Validation) Longitude(field interface{}, key string, message string) bool

func (*Validation) Max

func (v *Validation) Max(field interface{}, max int, key string, message string) bool

func (*Validation) Min

func (v *Validation) Min(field interface{}, min int, key string, message string) bool

func (*Validation) Numeric

func (v *Validation) Numeric(field interface{}, min int, key string, message string) bool

func (*Validation) Required

func (v *Validation) Required(field interface{}, key string, message string) bool

func (*Validation) URL

func (v *Validation) URL(field interface{}, key string, message string) bool

Jump to

Keyboard shortcuts

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