# Describe Request Added copyright header to the code. Fixes #112 # Change Type Documentation change.
33 lines
826 B
Go
33 lines
826 B
Go
// Package checker is a Go library for validating user input through struct tags.
|
|
//
|
|
// https://github.com/cinar/checker
|
|
//
|
|
// Copyright 2023 Onur Cinar. All rights reserved.
|
|
// Use of this source code is governed by a MIT-style
|
|
// license that can be found in the LICENSE file.
|
|
//
|
|
package checker
|
|
|
|
import (
|
|
"reflect"
|
|
"strings"
|
|
)
|
|
|
|
// NormalizerUpper is the name of the normalizer.
|
|
const NormalizerUpper = "upper"
|
|
|
|
// makeUpper makes a normalizer function for the upper normalizer.
|
|
func makeUpper(_ string) CheckFunc {
|
|
return normalizeUpper
|
|
}
|
|
|
|
// normalizeUpper maps all Unicode letters in the given value to their upper case.
|
|
func normalizeUpper(value, _ reflect.Value) Result {
|
|
if value.Kind() != reflect.String {
|
|
panic("string expected")
|
|
}
|
|
|
|
value.SetString(strings.ToUpper(value.String()))
|
|
|
|
return ResultValid
|
|
}
|