aboutsummaryrefslogtreecommitdiff
path: root/refined/condition.go
blob: 5b4355488ba7da56904545fd24d4ca08d39cd946 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
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
}