title: Vuejs: vuelidate conditional validation
body: <p>suppose we have a password field and we want to do some validations of length, specialcharacters, numbers, upper case and lower case etc, <strong>only if the field has a value</strong></p>
  
  <p>how can we do that with vuelidate.</p>
  
  <p>here I am import vuelidate</p>
  
  <pre><code>import { required, minLength, maxLength, email, sameAs } from 'vuelidate/lib/validators'
  </code></pre>
  
  <p>Here the validations</p>
  
  <pre><code>validations: {
      editedItem: {
        firstname: { required, minLength: minLength(3), maxLength: maxLength(20) },
        lastname: { required, minLength: minLength(3), maxLength: maxLength(20) },
        email: { required, email },
        password: {
          required,
          minLength: minLength(6),
          maxLength: maxLength(15),
          oneNumber,
          oneUpperCase,
          oneLowerCase,
        },
        repassword: {
          sameAsPassword: sameAs('password'),
        },
      },
    }
  </code></pre>
  
  <p>,</p>
  
  <p>oneNumber, oneUpperCase and oneLowerCase are custom validations:</p>
  
  <pre><code>const oneNumber = (value) =&gt; /[0-9]/.test(value)
  const oneUpperCase = (value) =&gt; /[A-Z]/.test(value)
  const oneLowerCase = (value) =&gt; /[a-z]/.test(value)
  </code></pre>
  
  <p>I will forever appreciate any help or advice</p>