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)
19
19
{
20
20
switch ( value )
21
21
{
22
+ case Uri valueAsUri :
23
+ {
24
+ return valueAsUri . Scheme == Uri . UriSchemeHttp
25
+ || valueAsUri . Scheme == Uri . UriSchemeHttps
26
+ || valueAsUri . Scheme == Uri . UriSchemeFtp ;
27
+ }
22
28
case string valueAsString :
23
29
{
24
30
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()
14
14
yield return new TestCase ( new UrlAttribute ( ) , "http://foo.bar" ) ;
15
15
yield return new TestCase ( new UrlAttribute ( ) , "https://foo.bar" ) ;
16
16
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" ) ) ;
17
20
}
18
21
19
22
protected override IEnumerable < TestCase > InvalidValues ( )
20
23
{
21
24
yield return new TestCase ( new UrlAttribute ( ) , "file:///foo.bar" ) ;
22
25
yield return new TestCase ( new UrlAttribute ( ) , "foo.png" ) ;
23
26
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" ) ) ;
24
29
}
25
30
26
31
[ Fact ]
You can’t perform that action at this time.
0 commit comments