vivin / regula

Regula: An annotation-based form-validation framework in Javascript
126 stars 24 forks source link

Can't validate a single element when two groups exist on the page #73

Closed jonahwh closed 9 years ago

jonahwh commented 9 years ago

If I have two inputs in two groups

<input data-constraints="@Required(groups=[Group1])" type="text" name="first_name" id="first_name">
<input data-constraints="@Required(groups=[Group2])" type="text" name="last_name" id="last_name">

And I try to validate either one

result = regula.validate({
    elements: [document.getElementById('first_name')]
});

or

result = regula.validate({
    elements: [document.getElementById('last_name')]
});

I get the following error:

Uncaught IllegalArgumentException: No constraints have been bound to the specified elements: first_name. Function received: {elements: [[object HTMLInputElement]], elementIds: [first_name]}

If I rename one of the groups so that there is only one group on the page, I am able to validate either field just fine.

JSFiddle

vivin commented 9 years ago

@crazydog115 Thanks for reporting the issue! I'll try to take a look at it this week!

vivin commented 9 years ago

@crazydog115 Sorry this took so long. I was busy with work and school. I've fixed the bug and I'll be pushing it up and making a new release shortly.

vivin commented 9 years ago

Fixed in v1.3.4.