0

我是 delpoyd 服务器的新手,需要验证电子邮件地址是否已经存在。我阅读了他的文档,但无法达到预期的效果。

根据部署的文档,我正在尝试这个。

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

如果有人知道,请帮助我。

4

1 回答 1

0

这是我用于验证电子邮件是否已经存在的代码。我在 Validate 事件中使用此代码。检查“PUT”方法的需要是为了防止用户将电子邮件 ID 更改为注册后已经存在的内容。

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");
    });
}
于 2016-01-24T14:58:51.980 回答