github.com/MontFerret/ferret@v0.18.0/pkg/stdlib/strings/case.go (about) 1 package strings 2 3 import ( 4 "context" 5 "strings" 6 7 "github.com/MontFerret/ferret/pkg/runtime/core" 8 "github.com/MontFerret/ferret/pkg/runtime/values" 9 ) 10 11 // LOWER converts strings to their lower-case counterparts. All other characters are returned unchanged. 12 // @param {String} str - The source string. 13 // @return {String} - THis string in lower case. 14 func Lower(_ context.Context, args ...core.Value) (core.Value, error) { 15 err := core.ValidateArgs(args, 1, 1) 16 17 if err != nil { 18 return values.EmptyString, err 19 } 20 21 text := strings.ToLower(args[0].String()) 22 23 return values.NewString(text), nil 24 } 25 26 // UPPER converts strings to their upper-case counterparts. All other characters are returned unchanged. 27 // @param {String} str - The source string. 28 // @return {String} - THis string in upper case. 29 func Upper(_ context.Context, args ...core.Value) (core.Value, error) { 30 err := core.ValidateArgs(args, 1, 1) 31 32 if err != nil { 33 return values.EmptyString, err 34 } 35 36 text := strings.ToUpper(args[0].String()) 37 38 return values.NewString(text), nil 39 }