I created an interest rate calculator however I modified the class to specify required and range attributes. When I add them and change my variables to null I receive the error: "Adding Attribute Error
This is the FutureValueModel.cs class producing the errors:
public class FutureValueModel
{
[Required(ErrorMessage = "Please enter a monthly investment.")]
[Range(1, 500, ErrorMessage =
"Monthly investment amount must be between 1 and 500.")]
public decimal? MonthlyInvestment { get; set; }
[Required(ErrorMessage = "Please enter a yearly interest rate.")]
[Range(0.1, 10.0, ErrorMessage =
"Yearly interest rate must be between 0.1 and 10.0.")]
public decimal? YearlyInterestRate { get; set; }
[Required(ErrorMessage = "Please enter a number of years.")]
[Range(1, 50, ErrorMessage =
"Number of years must be between 1 and 50.")]
public int? Years { get; set; }
Aucun commentaire:
Enregistrer un commentaire