From e9f573604c9700e1c4d549753d3d11e1f7c7fbea Mon Sep 17 00:00:00 2001 From: BrandonRomano Date: Fri, 23 Jun 2017 17:49:09 -0400 Subject: [PATCH] Satisfy linter --- null_handlers.go | 5 +++++ validator.go | 3 +-- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/null_handlers.go b/null_handlers.go index 5156bd2..2213efa 100644 --- a/null_handlers.go +++ b/null_handlers.go @@ -7,6 +7,7 @@ import ( "time" ) +// NullIntHandler is a TypeHandler for null.Int func NullIntHandler(input string, value *Value) error { // Get int64 res, err := strconv.ParseInt(input, 10, 64) @@ -21,6 +22,7 @@ func NullIntHandler(input string, value *Value) error { return nil } +// NullStringHandler is a TypeHandler for null.String func NullStringHandler(input string, value *Value) error { nullString := value.Result.(*null.String) (*nullString).String = input @@ -28,6 +30,7 @@ func NullStringHandler(input string, value *Value) error { return nil } +// NullFloatHandler is a TypeHandler for null.Float func NullFloatHandler(input string, value *Value) error { // Get float64 res, err := strconv.ParseFloat(input, 64) @@ -42,6 +45,7 @@ func NullFloatHandler(input string, value *Value) error { return nil } +// NullBoolHandler is a TypeHandler for null.Bool func NullBoolHandler(input string, value *Value) error { // Get bool res, err := strconv.ParseBool(input) @@ -56,6 +60,7 @@ func NullBoolHandler(input string, value *Value) error { return nil } +// NullTimeHandler is a TypeHandler for null.Time func NullTimeHandler(input string, value *Value) error { // Get time.Time res, err := time.Parse(time.RFC3339, input) diff --git a/validator.go b/validator.go index a04c097..ddd07aa 100644 --- a/validator.go +++ b/validator.go @@ -1,7 +1,6 @@ package validator import ( - "errors" "fmt" "reflect" "time" @@ -68,7 +67,7 @@ func Validate(values []*Value) error { func applyTypeHandler(value *Value) error { switch i := (value.Result).(type) { default: - return errors.New(fmt.Sprintf("go-carrot/validator cannot by default handle a Value with Result of type %v. Must set a custom TypeHandler for %v.", reflect.TypeOf(i), value.Name)) + return fmt.Errorf("go-carrot/validator cannot by default handle a Value with Result of type %v. Must set a custom TypeHandler for %v.", reflect.TypeOf(i), value.Name) case *string: value.TypeHandler = stringHandler case *float32: