jwaliszko / ExpressiveAnnotations

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

AssertThat doesn't take in consideration the custom or overriden value parsers #188

Closed evdinursan closed 6 years ago

evdinursan commented 6 years ago

Hi,

Awhile ago I had an issue (https://github.com/jwaliszko/ExpressiveAnnotations/issues/109) that was solved by a simple javascript 3 lines method.

Now, I discovered something very strange and maybe I'm doing something wrong because otherwise I cannot explain this.

I have a custom value parser method defined:

ea.addValueParser('numeric', function (value) {
    return customNumberParser(value);
});

That thing works great, but if I'm adding an AssertThat attribute like this:

[AssertThat("ServiceValueDiscount == null || ServiceValueDiscount <= NullableServiceContractedPrice", ErrorMessage = "You have an issue.")]

I'm getting this error:

[fail] (14:04:00): DOM field NullableServiceContractedPrice value conversion to number failed. Given value was not recognized as a valid number.

If I'm taking out the AssertThat attribute, the validation works great. Am I missing something or do you have any idea what is wrong?

Thanks. Evdin

jwaliszko commented 6 years ago

Hi, unfortunately in the meantime backward compatibility was broken. Instead of numeric please use number, i.e.

ea.addValueParser('number', function (value) {
    return customNumberParser(value);
});

Please excuse this issue. I need to prevent such a mistakes by further tests. Regards

evdinursan commented 6 years ago

Thank you!!! I will test and I will get back!

dum., 8 iul. 2018, 12:31 Jarosław Waliszko notifications@github.com a scris:

Hi, unfortunately in the meantime backward compatibility was broken. Instead of numeric please use number, i.e.

ea.addValueParser('number', function (value) { return customNumberParser(value); });

Please excuse this issue. I need to prevent such a mistakes by further tests. Regards

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/jwaliszko/ExpressiveAnnotations/issues/188#issuecomment-403275133, or mute the thread https://github.com/notifications/unsubscribe-auth/AGrOJzzeU4LlILJg2AuznV5CbgouWQfCks5uEdGJgaJpZM4VCZwL .

evdinursan commented 6 years ago

It's working perfectly. Thank you very much!