How to validate model attributes without using Data annotation in ASP.NET Core MVC

780 Views Asked by At

I want to validate models server-side in ASP.NET Core MVC:

public class Transaction
{
    [Key]
    public int Amount { get; set; }
    public int Account_Id { get; set; }
    public string Note { get; set; }
    public DateTime Date { get; set; }
}

I want to validate these attributes... like Amount cannot have negative values. But I shouldn't use model validation and data annotations, like this:

[StringLength(100)]
public string Note { get; set; }

In ASP.NET Core MVC, where and how can I validate this?

0

There are 0 best solutions below