Custom validation with multiple fields

A place for users and developers of the Xataface to discuss and receive support.

Custom validation with multiple fields

Postby iegroup21 » Sun Oct 23, 2011 6:04 am

Hello, I have a query regarding custom validation with multiple fields.

I'm trying to check if there are existing records with the same family name and given name in a table containing membership records.

The documentation found here (http://xataface.com/documentation/how-t ... validation) makes it sound like this is only possible with one field. So I would like to know if it is possible to create a validation rule that validates the input of multiple fields?

Thanks.
iegroup21
 
Posts: 4
Joined: Sun Oct 23, 2011 5:55 am

Re: Custom validation with multiple fields

Postby ADobkin » Sun Oct 23, 2011 11:15 pm

Perhaps this post might be helpful:

viewtopic.php?t=5503
ADobkin
 
Posts: 195
Joined: Mon Oct 22, 2007 7:31 pm
Location: Atlanta, GA, USA

Re: Custom validation with multiple fields

Postby iegroup21 » Mon Oct 24, 2011 11:24 pm

I have already explored setting the relevant fields in the database as unique but that equates to checking 1st field OR 2nd field for uniqueness but not 1st field AND 2nd field.

For example the database contains the following:

Kerry Smith
John Jackson

By setting the specific fields to unique, if a user types in John Smith, it will run up again the John and Smith in the database even though their is no "John Smith".
Using two "function _validate" in the delegate class also results in the same.

So is there a way to check for the combined uniqueness for multiple fields by using a _validate like function which can call multiple fields.

Thanks in advance.
iegroup21
 
Posts: 4
Joined: Sun Oct 23, 2011 5:55 am

Re: Custom validation with multiple fields

Postby shannah » Tue Oct 25, 2011 9:24 am

You can have multi-field indexes in MySQL. Just create a unique index containing both the firstname and lastname columns.
shannah
 
Posts: 4457
Joined: Wed Dec 31, 1969 5:00 pm

Re: Custom validation with multiple fields

Postby iegroup21 » Tue Oct 25, 2011 11:02 am

Thanks, The answer with the multifield indexes hit me a few hours after my last post.
iegroup21
 
Posts: 4
Joined: Sun Oct 23, 2011 5:55 am

Re: Custom validation with multiple fields

Postby chapin » Fri Jun 01, 2012 9:23 am

shannah wrote:You can have multi-field indexes in MySQL. Just create a unique index containing both the firstname and lastname columns.


Hello Steve!
Yes, I tried that. It works fine if I create a unique index on one field. Xataface throws a message telling me it is not possible to insert a repeated value. Then I create a new unique index on two fields. I try to insert a repeated tuple but it is not saved in the database, exactly as it should be expected. The problem is that I get a message like this: "New record created successfully" How can I fix this problem?

Btw Thank you very much for this great piece of software!!!
chapin
 
Posts: 12
Joined: Mon Aug 25, 2008 2:18 am


Return to Xataface Users

Who is online

Users browsing this forum: No registered users and 17 guests

cron
Powered by Dataface
© 2005-2007 Steve Hannah All rights reserved