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");
});
}