Vuelidate 2 / Vue composition API example.
See original GitHub issueI tried to get up and running with vuelidate 2 and the vue composition api.
I got as far as setting it up, and I have the validation model being returned, but its not totally working, the model updated but $dirty
and $valid
did not update.
Could we please get an example of how it should work?
Here is what i tried:
<script>
import { ref, reactive } from '@vue/composition-api'
import { email, required } from '@vuelidate/validators'
import useVuelidate from '@vuelidate/core'
import useLogin from '@/composables/auth/useLogin'
export default {
name: 'LoginForm',
setup() {
// Wrapping this in reactive since the plugin has a bug with .value
const loginService = reactive(useLogin())
const username = ref()
const password = ref()
const submit = () => {
loginService.login(username.value, password.value)
}
let validation = useVuelidate(
{
username: { required, email },
password: { required }
},
{ username, password }
)
return {
username,
password,
submit,
loginService,
validation
}
}
}
</script>
Issue Analytics
- State:
- Created 4 years ago
- Comments:12 (3 by maintainers)
Top Results From Across the Web
Vuelidate 2 - Composition API + Vue 3 - CodeSandbox
Template Info. Vuelidate 2 - Composition API + Vue 3. vue 3. validation. vuelidate ... App.vue. main.js .gitignore. README.md. babel.config.js. package.json.
Read more >Vuelidate: Getting started
Vuelidate 2 is a simple, but powerful, lightweight model-based validation for Vue.js 3 and 2. Vuelidate is considered model-based because the validation ...
Read more >A Guide To Vue 3 Form Validation - Vuelidate Tutorial
Vuelidate provides model-based validation for Vue projects. It's a simple, yet powerful way to add form validation into your projects because it ...
Read more >Vuelidate - A Lightweight Model-based Validation for Vue.js
To use Vuelidate with the Composition API, you need to provide it a state and set of validation rules, for that state. The...
Read more >Compose validation logics with Vue 3.0 and Vuelidate. - ITNEXT
The new vuelidate is implemented using Vue 3.0 composition api. It looks like below. One point is that you can not use reactive...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
hey @blowsie, can you post the full solution? I’m currently experiencing the same issue but I’m not sure what am I doing wrong.Thanks a lot @blowsie, I wouldn’t have figured out so quickly without your example
Here is my vue file
and my typescript file
Well, in that case, @ansarizafar keep your fingers crossed for this weekend! 🤞