MCPcopy Create free account
hub / github.com/baerwang/openapi-rs / test_pattern_validation_comprehensive

Function test_pattern_validation_comprehensive

src/validator/pattern_test.rs:192–245  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

190
191 #[test]
192 fn test_pattern_validation_comprehensive() {
193 let test_cases = [
194 TestCase::new(
195 "email",
196 EMAIL_PATTERN,
197 vec![
198 "test@example.com",
199 "user.name+tag@domain.co.uk",
200 "test123@test-domain.org",
201 ],
202 vec![
203 "invalid-email",
204 "test@",
205 "@domain.com",
206 "test.domain.com",
207 "test@domain",
208 ],
209 ),
210 TestCase::new(
211 "phone",
212 PHONE_PATTERN,
213 vec![
214 "(555) 123-4567",
215 "555-123-4567",
216 "5551234567",
217 "+1 555 123 4567",
218 ],
219 vec!["invalid-phone", "123", "555-123-456", "(555) 123-45678"],
220 ),
221 TestCase::new(
222 "ssn",
223 SSN_PATTERN,
224 vec!["123-45-6789", "000-00-0000", "999-99-9999"],
225 vec!["123456789", "123-4-5678", "1234-56-789", "123-456-789"],
226 ),
227 ];
228
229 for test_case in test_cases.iter() {
230 let param = create_parameter_with_pattern(
231 test_case.name,
232 Some(test_case.pattern.to_string()),
233 true,
234 );
235 let openapi = create_openapi_with_parameters(vec![param]);
236
237 for valid_value in &test_case.valid_values {
238 test_query_validation(&openapi, &[(test_case.name, valid_value)], true);
239 }
240
241 for invalid_value in &test_case.invalid_values {
242 test_query_validation(&openapi, &[(test_case.name, invalid_value)], false);
243 }
244 }
245 }
246
247 #[test]
248 fn test_schema_pattern_validation() {

Callers

nothing calls this directly

Calls 3

test_query_validationFunction · 0.85

Tested by

no test coverage detected