Skip to content

Make UrlAttribute work with the Uri data type #71008

@vanillajonathan

Description

@vanillajonathan

Is your feature request related to a problem? Please describe.

I am using ASP.NET Core and tries to validate my view model using the UrlAttribute but my property is of the Uri data type.

Describe the solution you'd like

UrlAttribute could work on the Uri data type too, not only the string data type.

Additional context

using System.ComponentModel.DataAnnotations;

namespace Example.Models;

public class ExampleModel
{
    [Url]
    public Uri Website { get; set; }
}
"The Website field is not a valid fully-qualified http, https, or ftp URL."

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions