Created
June 5, 2021 10:46
-
-
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
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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