checker/upper.go
Onur Cinar bdb9c8ea9b
Version v2. (#158)
# Describe Request

Version v2.

# Change Type

New version.
2024-12-29 05:12:21 -08:00

32 lines
831 B
Go

// Copyright (c) 2023-2024 Onur Cinar.
// Use of this source code is governed by a MIT-style
// license that can be found in the LICENSE file.
// https://github.com/cinar/checker
package v2
import (
"reflect"
"strings"
)
const (
// nameUpper is the name of the upper normalizer.
nameUpper = "upper"
)
// Upper maps all Unicode letters in the given value to their upper case.
func Upper(value string) (string, error) {
return strings.ToUpper(value), nil
}
// reflectUpper maps all Unicode letters in the given value to their upper case.
func reflectUpper(value reflect.Value) (reflect.Value, error) {
newValue, err := Upper(value.Interface().(string))
return reflect.ValueOf(newValue), err
}
// makeUpper returns the upper normalizer function.
func makeUpper(_ string) CheckFunc[reflect.Value] {
return reflectUpper
}