I have a view model ApplicantProfileModel
that works in all respects. It declares a property
[HiddenInput(DisplayValue = false)]
public int Id { get; set; }
and this property is present in a partial view like this
@model Comair.RI.UI.Models.ApplicantProfileModel
@Html.ValidationSummary(true)
<fieldset>
<legend></legend>
<ul class="form-column">
@Html.HiddenFor(m => m.Id)
.....
I have the following Fluent Validation rule for this property:
RuleFor(p => p.Id).NotEmpty().WithMessage("Id is empty. Messsage may have been tampered with.");
An int
with a value of zero is certainly not 'empty'. I know I can change the rule to not equal to zero, but that doesn't solve my problem and answer my question as to why an int
of value 0
is considered empty by fluent validation?