[Validator(typeof(foo))]
public class foo
{
public double? bar { get; set; }
}
public class fooValidator : AbstractValidator<foo>
{
public fooValidator()
{
RuleFor(x => x.bar)
.NotEmpty()
.GreaterThan(0d);
}
}
I then display the input field for bar
using the following:
@Html.EditorFor(model => model.Bar, new { @class = "form-control", htmlAttributes = new { @class = "form-control" } })
@Html.ValidationMessageFor(model => model.Bar)
However this presents some (to me) inexplicable behavior.
If I enter a number with a comma, e.g.: 1,1 it'll display an error message. However if the number has three, and only three (e.g. 19,800), numbers after the comma it'll gladly accept it as a valid input.
Why does this happen?