Skip to content

Instantly share code, notes, and snippets.

@isaacssemugenyi
Created June 5, 2021 10:46
Show Gist options
  • Save isaacssemugenyi/9f96c7c8ffc05f8971085cc4b9154bf0 to your computer and use it in GitHub Desktop.
Save isaacssemugenyi/9f96c7c8ffc05f8971085cc4b9154bf0 to your computer and use it in GitHub Desktop.
Validate method that we shall use to validate each input when a key is pressed, or a blur event occurs, validates against the ArticleSchema
methods: {
submitData() {
const submittedData = `${this.article.title} ${this.article.description}`;
alert(submittedData);
},
validate(field) {
ArticleSchema.validateAt(field, this.article)
.then(() => (this.errors[field] = ""))
.catch((err) => {
this.errors[err.path] = err.message;
});
},
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment