mirror of
https://github.com/superseriousbusiness/gotosocial.git
synced 2024-11-24 09:20:59 +00:00
review changes
This commit is contained in:
parent
a116676814
commit
32fe2282c4
1 changed files with 1 additions and 12 deletions
|
@ -27,11 +27,6 @@ import (
|
||||||
|
|
||||||
var v *validator.Validate
|
var v *validator.Validate
|
||||||
|
|
||||||
// Validation Panic messages
|
|
||||||
const (
|
|
||||||
InvalidPanic = "validate function was passed invalid item"
|
|
||||||
)
|
|
||||||
|
|
||||||
func ulidValidator(fl validator.FieldLevel) bool {
|
func ulidValidator(fl validator.FieldLevel) bool {
|
||||||
field := fl.Field()
|
field := fl.Field()
|
||||||
|
|
||||||
|
@ -52,13 +47,7 @@ func init() {
|
||||||
|
|
||||||
// Struct validates the passed struct, returning validator.ValidationErrors if invalid, or nil if OK.
|
// Struct validates the passed struct, returning validator.ValidationErrors if invalid, or nil if OK.
|
||||||
func Struct(s interface{}) error {
|
func Struct(s interface{}) error {
|
||||||
switch reflect.TypeOf(s).Kind() {
|
return processValidationError(v.Struct(s))
|
||||||
case reflect.Invalid:
|
|
||||||
panic(InvalidPanic)
|
|
||||||
}
|
|
||||||
|
|
||||||
err := v.Struct(s)
|
|
||||||
return processValidationError(err)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func processValidationError(err error) error {
|
func processValidationError(err error) error {
|
||||||
|
|
Loading…
Reference in a new issue