question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Unable to implement vuelidate with renderless component

See original GitHub issue

I 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:closed
  • Created 3 years ago
  • Comments:8 (4 by maintainers)

github_iconTop GitHub Comments

2reactions
dobromir-hristovcommented, Aug 17, 2020

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.

0reactions
power-cutcommented, Aug 17, 2020

@dobromir-hristov what if i want to implement validations as dynamic ?

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found