Skip to content

Instantly share code, notes, and snippets.

@IamManchanda
Created November 3, 2017 16:00
Show Gist options
  • Select an option

  • Save IamManchanda/e1f205b98c8e9b7d1954df5bbf62e0ae to your computer and use it in GitHub Desktop.

Select an option

Save IamManchanda/e1f205b98c8e9b7d1954df5bbf62e0ae to your computer and use it in GitHub Desktop.
import { Validator } from 'vee-validate';
import loginMixin from '../mixins/login';
import validateMixin from '../mixins/validate';
export default {
name: 'signup',
validator: null,
errors: null,
mixins: [loginMixin, validateMixin],
data() {
return {
name: '',
email: '',
password: '',
isVisible: false,
};
},
watch: {
email(value) {
this.validator.validate('email', value);
},
},
methods: {
doSignup() {
this.$validator.validateAll().then(() => {
this.isVisible = true;
const { name, email, password } = this;
this.register(name, email, password).then(() => {
this.$router.push({
name: 'profile',
});
}).catch((error) => {
// eslint-disable-next-line
console.log(error);
});
});
},
},
created() {
this.validator = new Validator({
email: 'required|email',
});
this.$set(this, 'errors', this.validator.errors);
},
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment