weapp/pkg/form/scrub.go

25 lines
416 B
Go
Raw Normal View History

2021-12-28 01:49:22 +08:00
package form
import (
"context"
"github.com/go-playground/mold/v4"
"github.com/go-playground/mold/v4/scrubbers"
)
var (
scrub = NewScrubbers()
)
func NewScrubbers() *mold.Transformer {
return scrubbers.New()
}
func ScrubStruct(v interface{}) error {
return ScrubStructWithContext(context.TODO(), v)
}
func ScrubStructWithContext(ctx context.Context, v interface{}) error {
return scrub.Struct(ctx, v)
}