judgegem / judge

Client-side form validation for Rails
MIT License
256 stars 41 forks source link

Validating uniqueness on a edit form broken #38

Closed donmcclean closed 9 years ago

donmcclean commented 10 years ago

When I attempt to update an existing record, the uniqueness validation for a field indicates the field value already is taken. It is not taking into account that the record I am editing is the one that has the existing value.

joecorcoran commented 9 years ago

Hmm, sounds bad. I'll try and look into this.

donmcclean commented 9 years ago

Thanks!

dannysperry commented 9 years ago

I'm also experiencing this, any ideas on what might be causing this? I'd be happy to look into it and submit a PR. I'm using: judge (~> 2.0.4) judge-simple_form (~> 0.4.0) rails (~> 4.1.4) simple_form (~> 3.0.2)

dannysperry commented 9 years ago

I ended up "fixing" this by storing the original value of the input in a variable and calling judge on the input if the input value != original value.

I attempted to find where this would be caught inside judge.js, but was a bit overwhelmed. I'd be happy to look deeper and possibly submit a PR if you have any suggestions on where to start.