jwaliszko / ExpressiveAnnotations

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

Empty model values replaced with \r\n, #185

Open Shilohe opened 6 years ago

Shilohe commented 6 years ago

Hi this is my first Issue ever ... so here goes. I've been using the EA package for about 8 months or more, it works really well but in diagnosing an issue with my code I think I've found a bug (or at least something I don't understand)

I use the the RequiredIf on several fields (reason for domain request and there are 12 domains), and I basically say if a checkbox item "a" is selected (this represents a domain) then text area "a" is required. So if Funding Domain is being requested then you have to provide a reason in an adjacent text area..

So I have a custom function which does the evaluations (one for the server and an equivalent one for the client). Everything works on the client, and everything kind of works on the server.... by which I mean, if you submit the and everything validates on the client it all works...But I do some server side validations as well... In this specific case I check to see if the requester already has an account (I check if we already have there email). So when this is true (the email already exists) it bounces back with a validation error. Again this is all expected and works correctly. So I fix the requester (its an email address). and step through the process again. This is when I start to see anomalies, 1st the empty fields, just the ones with the EA attributes from above have "\n," in them as in a new line and a comma, and the fields that did have data in them, again just the ones with the EA attributes now have their results doubled... as in if it said this "This is my reason, I need stuff and that's it" . It now says "This is my reason, I need stuff and that's it, This is my reason, I need stuff and that's it" and if you fix the original problem. replace the user email with one that isn't in use and resubmit now it rejects on all of those fields....

This doesn't effect any of the other validations on the page, many of which are also EA ... I finally determined it was the EA server-side dll, well I think I did, when I was stepping through my code and cleared the _html.ViewData.ModelState the fields rendered before all had the "\n," or the duplication, but the ones after didn't.

So I know this confusing but it looks like I have 2\3 related issues. 1) after server side post, and redirect values get duplicated or get a "\," added to them 2) On a 2nd post attempt (after fixing a different validation error) those same fields fail validation even though they passed the 1st time. 3) and the duplication happens again.

I've checked the model the values are fine there, its not until render that they get duplicated I have downloaded your code for the server side dll, but am not sure where to look for the issue.

Thanks in advance.... I don't mind fixing it if you can help me find it., and its within my abilities. Shiloh

jwaliszko commented 6 years ago

Hi, thank you for your effort in explaining this issue. Nevertheless it would be very helpful if you could find some spare time, and provide tiny yet reproducible code sample for me to compile and run. Is there a chance you could do it? It is hard for me to figure out what could have gone wrong by reading the description. I'm also not convinced issue is EA related but hard to say without such a sample.

Shilohe commented 6 years ago

yep... I'll give it shot...

On Tue, Apr 10, 2018 at 4:47 PM, Jarosław Waliszko <notifications@github.com

wrote:

Hi, thank you for your effort in explaining this issue. Nevertheless it would be very helpful if you could find some spare time, and provide tiny yet reproducible code sample for me to compile and run. Is there a chance you could do it? It is hard for me to figure out what could have gone wrong by reading the description. I'm also not convinced it is EA related but hard to say without such a sample.

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