In an MVC 5 project, I have a model with a nullable int. For reasons that might not be productive to explain, it needs to be an nullable int and cannot be a string.
// Value can be null or an integer from 0 to 145
[Range(0,145)]
public int? Criterion { get; set; }
The intended annotation is to provide user feedback when entering a value in a form.
Criterion: @Html.TextBoxFor(m => m.Criterion)
<span class="text-danger">@Html.ValidationMessageFor(m => m.Criterion)</span>
While the user does get feedback when entering non-integer values, the Range attribute does not appear to work.
In order to enforce a nullable integer range, will I need to use regular expressions, or is there a simpler way to enforce the rule?