Validating a date with C# and ASP.NET Core 3.1 I have a simple class to ensure the date entered into a form is a valid date. Where can I improve it, have I missed anything?
public class ValidDate : ValidationAttribute
{
    protected override ValidationResult IsValid(object value, ValidationContext validationContext)
    {
        var dateToParse = value.ToString();
        var parsedDate = new DateTime();

        if (DateTime.TryParseExact(dateToParse, &quot;dd/MM/yyyy&quot;, System.Globalization.CultureInfo.InvariantCulture,
            System.Globalization.DateTimeStyles.None, out parsedDate))
            return ValidationResult.Success;

        return new ValidationResult(&quot;Invalid date, please try again with a valid date in the format of DD/MM/YYYY.&quot;);
    }
}

Thanks,
You could easily turn your method into a one-liner expression-bodied method with a few tricks:

use the _ discard variable instead of the explicit parsedDate variable (also, it doesn't need initializing to new DateTime()).
use the conditional operator since you're returning one of two ValidationResults.
value.ToString() can be passed directly into TryParseExact without the extra local variable dateToParse.

Giving:
protected override ValidationResult IsValid(object value, ValidationContext validationContext) =&gt;
    DateTime.TryParseExact(value.ToString(), &quot;dd/MM/yyyy&quot;, System.Globalization.CultureInfo.InvariantCulture, System.Globalization.DateTimeStyles.None, out _)
        ? ValidationResult.Success
        : new ValidationResult(&quot;Invalid date, please try again with a valid date in the format of DD/MM/YYYY.&quot;);

Couple more items:

Recommend -- for ease of reading -- adding a using System.Globalization; to your namespace so you don't have to type that long prefix out twice.
As this is an attribute, add the suffix Attribute to your class name.