Skip to content

Instantly share code, notes, and snippets.

@trenskow
Created February 9, 2020 11:45
Show Gist options
  • Save trenskow/e387d73550a8df104253edcb4c9b4d8f to your computer and use it in GitHub Desktop.
Save trenskow/e387d73550a8df104253edcb4c9b4d8f to your computer and use it in GitHub Desktop.
How to check if two password are equal using invalid.
const user = await isvalid(/* data */,
{
type: Object,
schema: {
'username': { /* username validators */ },
'password': { type: String, required: true, match: /* some regular expression */ },
'password_repeated': { type: String, required: true }
},
post: (obj) {
if (obj.password !== obj.password_repeated) {
throw new Error('Passwords must be the same.');
}
}
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment