@@ -121,7 +121,6 @@ fn validate_str_length(value: &str, max_length: usize) -> Result<(), ValidationE
121
121
fn validate_str_regex (
122
122
value : & str ,
123
123
regex : & ' static Regex ,
124
- regex_str : & ' static str ,
125
124
error_msg : & ' static str ,
126
125
examples : & ' static [ & ' static str ] ,
127
126
) -> Result < ( ) , ValidationError > {
@@ -130,7 +129,11 @@ fn validate_str_regex(
130
129
} else {
131
130
Err ( RegexError {
132
131
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 ( '$' ) ,
134
137
examples,
135
138
}
136
139
. into ( ) )
@@ -159,7 +162,6 @@ pub fn is_rfc_1123_subdomain(value: &str) -> Result<(), ValidationErrors> {
159
162
validate_str_regex (
160
163
value,
161
164
& RFC_1123_SUBDOMAIN_REGEX ,
162
- RFC_1123_SUBDOMAIN_FMT ,
163
165
RFC_1123_SUBDOMAIN_ERROR_MSG ,
164
166
& [ "example.com" ] ,
165
167
) ,
@@ -174,7 +176,6 @@ pub fn is_rfc_1123_label(value: &str) -> Result<(), ValidationErrors> {
174
176
validate_str_regex (
175
177
value,
176
178
& RFC_1123_LABEL_REGEX ,
177
- RFC_1123_LABEL_FMT ,
178
179
RFC_1123_LABEL_ERROR_MSG ,
179
180
& [ "example-label" , "1-label-1" ] ,
180
181
) ,
@@ -188,7 +189,6 @@ pub fn is_rfc_1035_label(value: &str) -> Result<(), ValidationErrors> {
188
189
validate_str_regex (
189
190
value,
190
191
& RFC_1035_LABEL_REGEX ,
191
- RFC_1035_LABEL_FMT ,
192
192
RFC_1035_LABEL_ERROR_MSG ,
193
193
& [ "my-name" , "abc-123" ] ,
194
194
) ,
0 commit comments