Skip to content

Commit 3dcf7fd

Browse files
committed
Remove separate regex_str parameter
1 parent 1d1016d commit 3dcf7fd

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

crates/stackable-operator/src/validation.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -121,7 +121,6 @@ fn validate_str_length(value: &str, max_length: usize) -> Result<(), ValidationE
121121
fn validate_str_regex(
122122
value: &str,
123123
regex: &'static Regex,
124-
regex_str: &'static str,
125124
error_msg: &'static str,
126125
examples: &'static [&'static str],
127126
) -> Result<(), ValidationError> {
@@ -130,7 +129,11 @@ fn validate_str_regex(
130129
} else {
131130
Err(RegexError {
132131
msg: error_msg,
133-
regex: regex_str,
132+
regex: regex
133+
.as_str()
134+
// Clean up start/end-of-line markers
135+
.trim_start_matches('^')
136+
.trim_end_matches('$'),
134137
examples,
135138
}
136139
.into())
@@ -159,7 +162,6 @@ pub fn is_rfc_1123_subdomain(value: &str) -> Result<(), ValidationErrors> {
159162
validate_str_regex(
160163
value,
161164
&RFC_1123_SUBDOMAIN_REGEX,
162-
RFC_1123_SUBDOMAIN_FMT,
163165
RFC_1123_SUBDOMAIN_ERROR_MSG,
164166
&["example.com"],
165167
),
@@ -174,7 +176,6 @@ pub fn is_rfc_1123_label(value: &str) -> Result<(), ValidationErrors> {
174176
validate_str_regex(
175177
value,
176178
&RFC_1123_LABEL_REGEX,
177-
RFC_1123_LABEL_FMT,
178179
RFC_1123_LABEL_ERROR_MSG,
179180
&["example-label", "1-label-1"],
180181
),
@@ -188,7 +189,6 @@ pub fn is_rfc_1035_label(value: &str) -> Result<(), ValidationErrors> {
188189
validate_str_regex(
189190
value,
190191
&RFC_1035_LABEL_REGEX,
191-
RFC_1035_LABEL_FMT,
192192
RFC_1035_LABEL_ERROR_MSG,
193193
&["my-name", "abc-123"],
194194
),

0 commit comments

Comments
 (0)