package generic // Valid returns true if the argument is not nil and can be converted to the type. // if additional validators are required they can be given as arguments func Valid[T any](item any, validator ...func(T) bool) (ok bool) { if item != nil { var v, ok = item.(T) if len(validator) != 0 { for _, vali := range validator { ok = ok && vali(v) } } return ok } return false }