MCPcopy Create free account
hub / github.com/apache/answer / Sanitizer

Function Sanitizer

internal/base/validator/validator.go:140–155  ·  view source on GitHub ↗
(fl validator.FieldLevel)

Source from the content-addressed store, hash-verified

138}
139
140func Sanitizer(fl validator.FieldLevel) (res bool) {
141 field := fl.Field()
142 switch field.Kind() {
143 case reflect.String:
144 filter := bluemonday.UGCPolicy()
145 content := strings.ReplaceAll(filter.Sanitize(field.String()), "&", "&")
146 field.SetString(content)
147 return true
148 case reflect.Chan, reflect.Map, reflect.Slice, reflect.Array:
149 return field.Len() > 0
150 case reflect.Ptr, reflect.Interface, reflect.Func:
151 return !field.IsNil()
152 default:
153 return field.IsValid() && field.Interface() != reflect.Zero(field.Type()).Interface()
154 }
155}
156
157func createDefaultValidator(la i18n.Language) *validator.Validate {
158 validate := validator.New()

Callers

nothing calls this directly

Calls 1

SetStringMethod · 0.80

Tested by

no test coverage detected