Model:
public class TransactionViewModel
{
[Key]
public int Transaction_Id { get; set; }
public string Account_Name { get; set; }
public string Type { get; set; }
public string Note { get; set; }
public DateTime Date { get; set; }
public int Amount { get; set; }
public IEnumerable<TransactionViewModel> Transactions { get; set; }
}
I want to validate models then by model validations concept I will do something like this:
[Required]
[StringLength(100)]
public string Account_Name { get; set; } = null!;
[DataType(DataType.Date)]
public DateTime date { get; set; }
and wherever we want we will just use:
if (!ModelState.IsValid)
{
}
but is there any other way to validate these models levels? as it is only specific to asp.net core, I want to know other ways of how to validate these fields
Please answer this