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.

isUnique rule for collection on Vuelidate Next

See original GitHub issue

Hey Guys! I researched all issues and don’t understand how i can implement my rule isUnique for collection. Could you help me? Please 😦

I also looked at https://github.com/vuelidate/vuelidate/issues/781

So, for Vuelidate first version i had this solution

validations() {
  return {
    collection: {
      $each: {
        title: {
          isUnique: isUnique(this.collection, 'title')
        }
      }
    }
  };
},

and helper

export default function isUnique(group, key) {
  return (value) => {
    const found = group.filter(item => {
      if (key) {
        return item[key] === value;
      }
      return item === value;
    });

    return found.length <= 1;
  };
}

How i can migrate my solution for Vuelidate next?

Issue Analytics

  • State:open
  • Created a year ago
  • Comments:6 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
dobromir-hristovcommented, Oct 24, 2022

Create a simple repro in codesandbox and we can try to help

0reactions
yuri-kovalevcommented, Oct 24, 2022

This is very inconvenient for me, use another component for each object 😦

Read more comments on GitHub >

github_iconTop Results From Across the Web

Examples | Vuelidate
Collections validation #. A parent element will collect all of its child component validations. This allows for easy validation of collections. < ...
Read more >
Vuelidate | A Vue.js model validation library
Simple, lightweight model-based validation for Vue.js 2.0. Model based; Decoupled from templates; Dependency free, minimalistic library; Support for collection ...
Read more >
Ndianabasi Udonkang's Tech Blog
Validating the Contact Form with Vuelidate | Full-Stack Google ... The above rule will ensure that the isUnique async function is only ...
Read more >
How to properly add custom validation to array in vuelidate
I have an array of objects with the following structure ... I found the official guide here: vuelidate.js.org/#sub-collections-validation .
Read more >
Easy Form Validation With Vuelidate | Vue 3 - YouTube
Join My Weekly Dev Newsletter: https://www.johnkomarnicki.com/#newsletterForm validation is an essential part of any form, and you want to ...
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