How To- Two validation properties for "Exist in Database"

A little background… I need to validate a new user by asking them to provide me with two pieces of information that should already exist in one row of our database. I have a form that has the two fields and I am using the Validate Data in Server Connect.

I am using the tutorial on how to validate if a record exist in a database. I followed the tutorial and it works great for one validation, but not for two. So if one value out of the two columns is a match, I get a status 200 but I need it to match both. Is this possible? Is there an easy way to do this?


Thanks in advance for any suggestions and help.

I don’t think this is possible with the validator as it’s not possible to choose AND for the conditions (only OR). I think there may be an outstanding feature request for this but I can’t find it. It would a much more useful feature if it had this functionality. You could use a condition instead.

1 Like

As Tom points out, the validator uses OR…and I agree, we need an AND option.

You can use a second validator step to almost get to the same place. It will work, however the 2nd validation will not execute if the first one fails, which prevents both fields from displaying the feedback to the user.

2 Likes

Thanks guys, I appreciate the replies and advice.

@mebeingken, keep those awesome videos coming!

1 Like

So I tried using two validations. If the first one validates and the second one does not, response 400. If the first one does not validate but the second one does, it returns a 200. Looks like if there are multiple, it goes off the last one. I will try and use conditional steps and see if that works.

Hmmmm, not what I’m seeing.

First validate is make, second is model.

If both values exist in db (this is where I wish both validation messages would show):

If Make is new, but Model exists:

If Make exists, but new model:

If both are new:

Are you doing it as two steps in your Server connect file?


or is it two different validations in separate server connect files, one for each field?

Two steps in one api, like you’ve shown.

First:

Second:

Ah, I see there is a difference in that I am validating “Exist in Database” and you are validating “Does Not Exist in Database”. I tried it your way and it does validate each one like you show, but I need to make sure both values do exist and if not, return a message. I guess opposite of how you would usually do it.

What I’m trying to accomplish is being able to allow a user to sign up only if they are able to provide two fields of data in the database. Maybe there is a better way to accomplish this. I guess I could just validate one piece of data for now.

Thanks again for your time and assistance.

I think that is working too…but Tom’s suggestion of a condition may be what you want. Do a query, and react based on the result.

But the validate does work with Exists in DB, with the same caveat that only one message can be returned (the first to fail).

Ok, so I had an idea. I was thinking hey, this is just like logging someone in. It asks for credentials, and if they are met, it goes to the next page. So that’s what I tried to do…except now it looks like there is a bug that I can’t see the new security provider I just added. This is using Node.JS