Skip to content

Instantly share code, notes, and snippets.

@skomarfaruque
Last active October 26, 2017 12:37
Show Gist options
  • Save skomarfaruque/0b362c50e275c77bde43ce07f6b0bfff to your computer and use it in GitHub Desktop.
Save skomarfaruque/0b362c50e275c77bde43ce07f6b0bfff to your computer and use it in GitHub Desktop.
v-validate="{ rules: { required: true, regex: /\b(0[1-9]|1[0-2])\/?([0-9]{4}|[0-9]{2})\b/} }" //inline regex
custom:
this.$validator.extend('emailexists', { // checks if the email is already in db
getMessage: field => 'Your email is in our record.Please check your email to login',
validate: async value => {
let response = await fetch(`${process.env.baseUrl}/users/auth/searchbyquery?email=${value}`, {
method: 'GET',
headers: {'Content-Type': 'Application/json'}
})
let result = await response.json()
if (result.success && result.data) {
return false
} else {
return true
}
}
})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment