Hello Ronald, thanks for the suggestions ;) i think the former option would work although seems odd to have two custom validators running for one input array. I wonder if there is a way to manage the validation of the whole array (including removing duplicates and checking address validity) but set a validation error for a specific item?
thanks Hash On 21 May 2012, at 13:26, Ronald Becher wrote: > Hi Hash (well, this name already fits the solution ... :) , > > You basically have two options: > - Either prepend a validator that throws out duplicates (i.e. sorts them into > a hash) > - Export a list of already created accounts (i.e, in this run) and check > against that list ... if your current email adress matches already exists, > just skip it and return the unchanged "list of already created accounts" > > Hope that helps! > > Regards, > Ronald > > Am 20.05.2012 22:51, schrieb Hash: >> Dear Agavi Users, >> >> i would like to know how best to remove duplicate post data using a custom >> validator. The scenario is that i am posting a form relating to a 'Contact' >> entity which has related entities of email addresses. >> >> Currently i have implemented a custom validator with a base="emails[]" and >> everything is fine until the user inputs for example, the same email address >> twice. The email entity is looked up twice since the validator runs for each >> item in the emails[] array. These entities get through to the database and i >> get a constraint exception in my Contact-Email link table. I would like my >> validator to detect and skip any duplicates in the posted data, but my >> validator only seems to have the scope of the current item in emails[]. >> >> I guess i could pass the whole emails array as an argument into the >> validator and loop over each email removing duplicates first, but then i'm >> not sure how to throw an error with the correct context for an email address >> that is invalid.. >> >> Validator: http://pastebin.com/np1m80ib >> XML: http://pastebin.com/jjwQdEA5 >> >> Please advise. thank you. >> >> Hash >> _______________________________________________ >> users mailing list >> [email protected] >> http://lists.agavi.org/mailman/listinfo/users > > > _______________________________________________ > users mailing list > [email protected] > http://lists.agavi.org/mailman/listinfo/users _______________________________________________ users mailing list [email protected] http://lists.agavi.org/mailman/listinfo/users
