jwaliszko / ExpressiveAnnotations

Annotation-based conditional validation library.
MIT License
351 stars 123 forks source link

throwed exception with decimal data type? #44

Closed cuongtructran closed 9 years ago

cuongtructran commented 9 years ago

Hi Waliszko,

I have a sample model like below:

[RequiredIf("Test == null", ErrorMessage = "Test validation")] [AssertThat("Test <= 0", ErrorMessage = "Test validation")] public decimal Test { get; set; }

and a view:

@Html.TextBoxFor(g => g.Test) @Html.ValidationMessageFor(g => g.Test)

When I start the page, the exception throws with the exception message like this: "Parse fatal error. The binary operator Equal is not defined for the types 'System.Double' and 'System.Object'."

Could you please take a look on this problem? I could not find any example with decimal data type on your sample project.

Thank You.

jwaliszko commented 9 years ago

Hi,

Decimal is a value type. It cannot be null. You should use nullable version instead:

public decimal? Test { get; set; }