@@ -1048,40 +1048,66 @@ mod tests {
10481048 r#"{"title": "Foo", "type": "string", "format": "uri"}"# ,
10491049 URI ,
10501050 vec ! [
1051- " http://example.com",
1052- " https://example.com/path?query=param#fragment",
1053- " ftp://ftp.example.com/resource",
1054- " urn:isbn:0451450523",
1051+ r#"" http://example.com""# ,
1052+ r#"" https://example.com/path?query=param#fragment""# ,
1053+ r#"" ftp://ftp.example.com/resource""# ,
1054+ r#"" urn:isbn:0451450523""# ,
10551055 ] ,
10561056 vec ! [
1057- " http:/example.com", // missing slash
1058- " htp://example.com", // invalid scheme
1059- " http://", // missing host
1060- " example.com", // missing scheme
1057+ r#"" http:/example.com""# , // missing slash
1058+ r#"" htp://example.com""# , // invalid scheme
1059+ r#"" http://""# , // missing host
1060+ r#"" example.com""# , // missing scheme
10611061 ]
10621062 ) ,
10631063 (
10641064 r#"{"title": "Bar", "type": "string", "format": "email"}"# ,
10651065 EMAIL ,
10661066 vec ! [
10671067 // Valid emails
1068- 1069- 1070- 1071- 1068+ r#"" [email protected] ""# , // valid 1069+ r#"" [email protected] ""# , // valid 1070+ r#"" [email protected] ""# , // valid 1071+ r#"" [email protected] ""# , // valid 10721072 ] ,
10731073 vec ! [
10741074 // Invalid emails
1075- "plainaddress" , // missing '@' and domain
1076- "@missingusername.com" , // missing username
1077- "[email protected] " , // leading dot in domain 1078- "username@com" , // TLD must have at least 2 characters
1079- "username@example,com" , // invalid character in domain
1080- "[email protected] " , // leading dot in domain 1081- "[email protected] " , // domain cannot start with a hyphen 1082- "[email protected] " , // domain cannot end with a hyphen 1083- "[email protected] " , // double dot in domain name 1084- "[email protected] " , // multiple errors in domain 1075+ r#""plainaddress""# , // missing '@' and domain
1076+ r#""@missingusername.com""# , // missing username
1077+ r#""[email protected] ""# , // leading dot in domain 1078+ r#""username@com""# , // TLD must have at least 2 characters
1079+ r#""username@example,com""# , // invalid character in domain
1080+ r#""[email protected] ""# , // leading dot in domain 1081+ r#""[email protected] ""# , // domain cannot start with a hyphen 1082+ r#""[email protected] ""# , // domain cannot end with a hyphen 1083+ r#""[email protected] ""# , // double dot in domain name 1084+ r#""[email protected] ""# , // multiple errors in domain 1085+ ]
1086+ ) ,
1087+ // Nested URI and email
1088+ (
1089+ r#"{
1090+ "title": "Test Schema",
1091+ "type": "object",
1092+ "properties": {
1093+ "test_str": {"title": "Test string", "type": "string"},
1094+ "test_uri": {"title": "Test URI", "type": "string", "format": "uri"},
1095+ "test_email": {"title": "Test email", "type": "string", "format": "email"}
1096+ },
1097+ "required": ["test_str", "test_uri", "test_email"]
1098+ }"# ,
1099+ format ! (
1100+ r#"\{{{0}"test_str"{0}:{0}{STRING}{0},{0}"test_uri"{0}:{0}{URI}{0},{0}"test_email"{0}:{0}{EMAIL}{0}\}}"# ,
1101+ WHITESPACE
1102+ ) . as_str ( ) ,
1103+ vec ! [
1104+ r#"{ "test_str": "cat", "test_uri": "http://example.com", "test_email": "[email protected] " }"# , 1105+ ] ,
1106+ vec ! [
1107+ // Invalid URI
1108+ r#"{ "test_str": "cat", "test_uri": "http:/example.com", "test_email": "[email protected] " }"# , 1109+ // Invalid email
1110+ r#"{ "test_str": "cat", "test_uri": "http://example.com", "test_email": "[email protected] " }"# , 10851111 ]
10861112 ) ,
10871113
0 commit comments