Unable to implement vuelidate with renderless component
See original GitHub issueI want to create a renderless form with vuejs - I’m using vuelidate for form validation. The form uses scoped slot to manage the model and controls.
Unfortunately i’m not able to implement the vuelidate for the form validation by renderless approach. Any ideas would be highly appreciated. Below is what i have tried.
App.vue
<renderless-form>
<form @submit.prevent="submit" slot-scope="{ ele, submit }">
<input type="email" v-model="ele.model.name" />
<button> Submit </button>
</form>
</renderless-form>
<script>
import renderlessFrom from "./components/renderless-form.vue";
export default {
name: "App",
components: {
"renderless-form": renderlessFrom
}
};
</script>
Renderless-form.vue
import { required, minLength, between } from "vuelidate/lib/validators";
export default {
data() {
return {
model: {
name: ''
}
};
},
validation: model, //i am sceptical here how to put validation
methods: {
async submit() {
console.log(this.model)
},
},
render() {
return this.$scopedSlots.default({
// Data
ele: this.model,
// Methods
submit: this.submit,
});
},
};
Issue Analytics
- State:
- Created 3 years ago
- Comments:8 (4 by maintainers)
Top Results From Across the Web
unable to implement vuelidate with renderless component ...
Unfortunately i'm not able to implement the vuelidate for the form validation by renderless approach. Any ideas would be highly appreciated.
Read more >unable to implement vuelidate with renderless component
Coding example for the question unable to implement vuelidate with renderless component - vue js-Vue.js.
Read more >$each with Vuelidate next is no longer a property #781 - GitHub
The way I've compromised is to use a reusable renderless component that accepts props for fields and rules, and sends a slot prop...
Read more >Understanding Renderless Components in Vue - Telerik
In this article we're going to learn how to create renderless components in Vue, and how and when to use them.
Read more >Vuelidate: Effortless Error Messaging | by Chris Mitchell
Create a component that handles rendering errors, providing a simple but rigid way to display errors. · Use a renderless component that passes...
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
Pass them as a prop or just dynamic for this form?
You can still return an object from inside the
validations
function, making your rules dynamic.@dobromir-hristov what if i want to implement validations as dynamic ?