update all example references to v8

pull/170/head
joeybloggs 9 years ago
parent aa72515d75
commit d5f9115ad5
  1. 6
      README.md
  2. 9
      examples/custom/custom.go
  3. 20
      examples/simple/simple.go
  4. 3
      examples_test.go

@ -2,9 +2,9 @@ Package validator
================
[![Join the chat at https://gitter.im/bluesuncorp/validator](https://badges.gitter.im/Join%20Chat.svg)](https://gitter.im/bluesuncorp/validator?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge)
[![Build Status](https://semaphoreci.com/api/v1/projects/ec20115f-ef1b-4c7d-9393-cc76aba74eb4/517072/badge.svg)](https://semaphoreci.com/joeybloggs/validator)
[![Coverage Status](https://coveralls.io/repos/bluesuncorp/validator/badge.svg?branch=v7&service=github)](https://coveralls.io/github/bluesuncorp/validator?branch=v7)
[![GoDoc](https://godoc.org/gopkg.in/bluesuncorp/validator.v7?status.svg)](https://godoc.org/gopkg.in/bluesuncorp/validator.v7)
[![Build Status](https://semaphoreci.com/api/v1/projects/ec20115f-ef1b-4c7d-9393-cc76aba74eb4/530054/badge.svg)](https://semaphoreci.com/joeybloggs/validator)
[![Coverage Status](https://coveralls.io/repos/bluesuncorp/validator/badge.svg?branch=v8&service=github)](https://coveralls.io/github/bluesuncorp/validator?branch=v8)
[![GoDoc](https://godoc.org/gopkg.in/bluesuncorp/validator.v8?status.svg)](https://godoc.org/gopkg.in/bluesuncorp/validator.v8)
Package validator implements value validations for structs and individual fields based on tags.

@ -6,7 +6,7 @@ import (
"fmt"
"reflect"
"gopkg.in/bluesuncorp/validator.v7"
"gopkg.in/bluesuncorp/validator.v8"
)
// DbBackedUser User struct
@ -17,10 +17,7 @@ type DbBackedUser struct {
func main() {
config := validator.Config{
TagName: "validate",
ValidationFuncs: validator.BakedInValidators,
}
config := &validator.Config{TagName: "validate"}
validate := validator.New(config)
@ -30,7 +27,7 @@ func main() {
x := DbBackedUser{Name: sql.NullString{String: "", Valid: true}, Age: sql.NullInt64{Int64: 0, Valid: false}}
errs := validate.Struct(x)
if len(errs) > 0 {
if errs != nil {
fmt.Printf("Errs:\n%+v\n", errs)
}
}

@ -7,7 +7,7 @@ import (
sql "database/sql/driver"
"gopkg.in/bluesuncorp/validator.v7"
"gopkg.in/bluesuncorp/validator.v8"
)
// User contains user information
@ -32,10 +32,7 @@ var validate *validator.Validate
func main() {
config := validator.Config{
TagName: "validate",
ValidationFuncs: validator.BakedInValidators,
}
config := &validator.Config{TagName: "validate"}
validate = validator.New(config)
@ -67,7 +64,7 @@ func validateStruct() {
fmt.Println(errs) // output: Key: "User.Age" Error:Field validation for "Age" failed on the "lte" tag
// Key: "User.Addresses[0].City" Error:Field validation for "City" failed on the "required" tag
err := errs["User.Addresses[0].City"]
err := errs.(validator.ValidationErrors)["User.Addresses[0].City"]
fmt.Println(err.Field) // output: City
fmt.Println(err.Tag) // output: required
fmt.Println(err.Kind) // output: string
@ -135,17 +132,10 @@ func ValidateValuerType(field reflect.Value) interface{} {
func main2() {
customTypes := map[reflect.Type]validator.CustomTypeFunc{}
customTypes[reflect.TypeOf((*sql.Valuer)(nil))] = ValidateValuerType
customTypes[reflect.TypeOf(valuer{})] = ValidateValuerType
config := validator.Config{
TagName: "validate",
ValidationFuncs: validator.BakedInValidators,
CustomTypeFuncs: customTypes,
}
config := &validator.Config{TagName: "validate"}
validate2 = validator.New(config)
validate2.RegisterCustomTypeFunc(ValidateValuerType, (*sql.Valuer)(nil), valuer{})
validateCustomFieldType()
}

@ -3,8 +3,7 @@ package validator_test
import (
"fmt"
// "gopkg.in/bluesuncorp/validator.v7"
"../validator"
"gopkg.in/bluesuncorp/validator.v8"
)
func ExampleValidate_new() {

Loading…
Cancel
Save