Sowmya Sirsi

Sowmya Sirsi

  • NA
  • 173
  • 44.2k

Integer validation in asp.net core

Sep 16 2021 2:53 PM

Hi Team,

I tried model validation for integer as below: where it is not working for null or empty field

1) [Required]

    public int? UsecaseID { get; set; }

2) [Range(1, int.MaxValue, ErrorMessage = "Value for {0} must be between {1} or {2} or {3}.")]
     public int UsecaseID { get; set; }

 

Please assist me with any other option?

 


Answers (3)