diff --git a/components/contracts/system_dispatcher.go b/components/contracts/system_dispatcher.go index 1f7674a..ff360c0 100644 --- a/components/contracts/system_dispatcher.go +++ b/components/contracts/system_dispatcher.go @@ -1204,6 +1204,12 @@ type IDispatcher interface { Trim(input string) string // Contains reports whether substr is within s. Contains(input, substr string) bool + // ToUpper returns input with all Unicode letters mapped to their upper case. + ToUpper(input string) string + // MatchString reports whether the string input + // contains any match of the regular expression pattern. + // More complicated queries need to use Compile and the full Regexp interface. + MatchString(pattern string, input string) bool // IsEmpty checks whether the provided string is empty. Trims the spaces in the string first. IsEmpty(input string) bool // IsNotEmpty checks whether the provided string is not empty. Trims the spaces in the string first. diff --git a/components/core/system_dispatcher.go b/components/core/system_dispatcher.go index 3f704e9..6fa3ff0 100644 --- a/components/core/system_dispatcher.go +++ b/components/core/system_dispatcher.go @@ -5,6 +5,7 @@ import ( "fmt" "math/rand" "net/http" + "regexp" "sort" "strings" "time" @@ -288,6 +289,19 @@ func (dispatcher *dispatcher) Contains(input, substr string) bool { return strings.Contains(input, substr) } +func (dispatcher *dispatcher) ToUpper(input string) string { + return strings.ToUpper(input) +} + +func (dispatcher *dispatcher) MatchString(pattern string, input string) bool { + matched, err := regexp.MatchString(pattern, input) + if err != nil { + panic(err.Error()) + } + + return matched +} + func (dispatcher *dispatcher) IsEmpty(input string) bool { return strings.TrimSpace(input) == "" }