File tree Expand file tree Collapse file tree 2 files changed +11
-0
lines changed
src/libraries/System.ComponentModel.Annotations
src/System/ComponentModel/DataAnnotations
tests/System/ComponentModel/DataAnnotations Expand file tree Collapse file tree 2 files changed +11
-0
lines changed Original file line number Diff line number Diff line change @@ -19,6 +19,12 @@ public override bool IsValid(object? value)
1919 {
2020 switch ( value )
2121 {
22+ case Uri valueAsUri :
23+ {
24+ return valueAsUri . Scheme == Uri . UriSchemeHttp
25+ || valueAsUri . Scheme == Uri . UriSchemeHttps
26+ || valueAsUri . Scheme == Uri . UriSchemeFtp ;
27+ }
2228 case string valueAsString :
2329 {
2430 return valueAsString . StartsWith ( "http://" , StringComparison . OrdinalIgnoreCase )
Original file line number Diff line number Diff line change @@ -14,13 +14,18 @@ protected override IEnumerable<TestCase> ValidValues()
1414 yield return new TestCase ( new UrlAttribute ( ) , "http://foo.bar" ) ;
1515 yield return new TestCase ( new UrlAttribute ( ) , "https://foo.bar" ) ;
1616 yield return new TestCase ( new UrlAttribute ( ) , "ftp://foo.bar" ) ;
17+ yield return new TestCase ( new UrlAttribute ( ) , new Uri ( "http://foo.bar" ) ) ;
18+ yield return new TestCase ( new UrlAttribute ( ) , new Uri ( "https://foo.bar" ) ) ;
19+ yield return new TestCase ( new UrlAttribute ( ) , new Uri ( "ftp://foo.bar" ) ) ;
1720 }
1821
1922 protected override IEnumerable < TestCase > InvalidValues ( )
2023 {
2124 yield return new TestCase ( new UrlAttribute ( ) , "file:///foo.bar" ) ;
2225 yield return new TestCase ( new UrlAttribute ( ) , "foo.png" ) ;
2326 yield return new TestCase ( new UrlAttribute ( ) , new object ( ) ) ;
27+ yield return new TestCase ( new UrlAttribute ( ) , new Uri ( "file:///foo.bar" ) ) ;
28+ yield return new TestCase ( new UrlAttribute ( ) , new Uri ( "//foo.png" ) ) ;
2429 }
2530
2631 [ Fact ]
You can’t perform that action at this time.
0 commit comments