checker/trim.go
Onur Cinar 4bf287b006
Fix overview. (#116)
# Describe Request

Fix overview.

# Change Type

Document change.
2023-06-24 20:55:03 -07:00

25 lines
547 B
Go

package checker
import (
"reflect"
"strings"
)
// NormalizerTrim is the name of the normalizer.
const NormalizerTrim = "trim"
// makeTrim makes a normalizer function for the trim normalizer.
func makeTrim(_ string) CheckFunc {
return normalizeTrim
}
// normalizeTrim removes the whitespaces at the beginning and at the end of the given value.
func normalizeTrim(value, _ reflect.Value) Result {
if value.Kind() != reflect.String {
panic("string expected")
}
value.SetString(strings.Trim(value.String(), " \t"))
return ResultValid
}