rpgkaiser / FoolProof.Core

Migration to asp.net core of the "MVC Foolproof Validation" library.
MIT License
53 stars 17 forks source link

values with format { HH:mm } e.g. 20:00 parsed as date in mvcfoolproof.core.js #19

Closed IQUAYE closed 3 years ago

IQUAYE commented 3 years ago

I am trying to validate two time-input fields using [GreaterThan] attribute with value formatted from the server as {HH:mm}.

But the validation error message was always the same irrespective of the values I input in both fields.

Upon inspecting the mvcfoolproof.core.js, I realised such formats are parsed as dates during the call to isDate() method which gets called before the isTime() method. Eventually, the input value gets validated as a date field thereby failing the validation every time.

BTW, I made it work in my code by changing the positions of the isTime() and isDate() methods so that my time values are validated as time even before the isDate() method is called.

rpgkaiser commented 3 years ago

Yep, the regex used by the isDate utility function is accepting time only values as valid DateTimes. I'll try to adjust it to requires the date part, but not sure when i'll get this ready. Although your change is also a valid one.

rpgkaiser commented 3 years ago

Hi @IQUAYE,

I just released a new version (v1.1.9) with the fixes for this issue. Thanks you very much for your help!

IQUAYE commented 3 years ago

Welcome @rpgkaiser, you did and are still doing a great job