Last active
January 3, 2021 09:55
-
-
Save crishellco/87342a5010c4aa79a96955597cacb0a4 to your computer and use it in GitHub Desktop.
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
| <template> | |
| <section> | |
| <form-group :validations="$v.name" class="form-group"> | |
| <div slot-scope="{ errors, invalid }"> | |
| <div> | |
| <input | |
| v-model="$v.name.$model" | |
| type="text" | |
| :class="{ invalid }" | |
| placeholder="Full name" | |
| /> | |
| </div> | |
| <span v-for="error in errors" class="error">{{ error }}</span> | |
| </div> | |
| </form-group> | |
| <form-group :validations="$v.email" class="form-group"> | |
| <div slot-scope="{ errors, invalid }"> | |
| <div> | |
| <input | |
| v-model="$v.email.$model" | |
| type="email" | |
| :class="{ invalid }" | |
| placeholder="Email" | |
| /> | |
| </div> | |
| <span v-for="error in errors" class="error">{{ error }}</span> | |
| </div> | |
| </form-group> | |
| </section> | |
| </template> | |
| <script> | |
| import { email, helpers, required, minLength } from "vuelidate/lib/validators"; | |
| import FormGroup from "./FormGroup"; | |
| const alpha = helpers.regex("alpha", /^[a-zA-Z\s]*$/); | |
| export default { | |
| components: { | |
| FormGroup, | |
| }, | |
| data() { | |
| return { | |
| email: "", | |
| name: "", | |
| }; | |
| }, | |
| validations: { | |
| email: { | |
| email, | |
| required, | |
| }, | |
| name: { | |
| alpha, | |
| minLength: minLength(10), | |
| required, | |
| } | |
| }, | |
| }; | |
| </script> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment