Hi! I have a form with a table of IP-ranges (fromip, toip) that are related to an object the user is editing through a has_many relation. I need to validate the IP-ranges to check that it's a valid IP, that fromip is less thant toip, and that the range as a whole does not collide with another range.
Checking that one IP is valid is easy, I just add a condition to the elements containing fromip and toip. But checking the range is harder. The first thing I want to check is if one IP is inside another range. If I search the database for ranges where newip >= fromip and newip <= toip, I will find any conflicting ranges, but I will also find the range I'm editing if this is an update. What's the best way to avoid this? I tried earlier to add a validator on a block surrounding the primary key, fromip and twoip in this form. When I did this, validate was called with $values containing all three fields. I could then check that the conflicting range did not have the same primary key, and I could check if fromip and toip was in the correct order. But it was not a very clean way to do it. If i were to change the order of these fields in the yml-file, it would break. And in the newest HTML::FormFu version, it seems validate is called on one element at a time. Is there a better way to do this? Regards, Henning Kulander _______________________________________________ HTML-FormFu mailing list [email protected] http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/html-formfu
