feat(components): enhance system dispatcher methods

master
Xeronith 2023-05-26 20:55:39 +03:30
rodzic a204dd2600
commit 051938cbf4
2 zmienionych plików z 20 dodań i 0 usunięć

Wyświetl plik

@ -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.

Wyświetl plik

@ -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) == ""
}