0

I am new in delpoyd server and need to validate email address already exist. I read his document but unable to achieve result as expected.

According to deployd doc, I was trying this.

dpd['to-do'].get(query, function (result) {   console.log(result); });

Please help me if anyone know.

1 Answers1

0

This is the code I use for validating whether email already exists.I use this code in the Validate event.The need for checking the method 'PUT' is to prevent users from changing the email id to something that already exists after registering.

function validate(result, field) {
    if (method === 'PUT') {
        if (result.length === 0) {
        } else if (!(result.length === 1 && result[0].id === id)) {
            error(field, field + " is already in use");
        }
    } else if (result.length !== 0) {
        error(field, field + " is already in use");
    }
}
if (!internal) {
    var email;
    var method = ctx.method;
    email = {
        "email": this.email
    };
    dpd.users.get(email, function (result) {
        validate(result, "email");
    });
}
Raghu
  • 909
  • 7
  • 23