aboutsummaryrefslogtreecommitdiff
path: root/refined/condition.go
diff options
context:
space:
mode:
Diffstat (limited to 'refined/condition.go')
-rw-r--r--refined/condition.go20
1 files changed, 20 insertions, 0 deletions
diff --git a/refined/condition.go b/refined/condition.go
new file mode 100644
index 0000000..5b43554
--- /dev/null
+++ b/refined/condition.go
@@ -0,0 +1,20 @@
+/*******************************************************************************
+* Copyright 2025 Stefan Majewsky <majewsky@gmx.net>
+* SPDX-License-Identifier: Apache-2.0
+* Refer to the file "LICENSE" for details.
+*******************************************************************************/
+
+package refined
+
+import (
+ "fmt"
+ "regexp"
+)
+
+// Building block for writing MatchesValue() implementations.
+func RegexpMatch(rx *regexp.Regexp, value string) error {
+ if !rx.MatchString(value) {
+ return fmt.Errorf("provided value %q does not match expected pattern %q", value, rx.String())
+ }
+ return nil
+}