0

I have 4 inputs, all must be required( witch I did, and works), but first input must be equal with the next 3 fields, witch is not working with my current code. (also I get no error in console)

import { required, minValue } from "vuelidate/lib/validators";
// ..code...
created() {
    const minValue = (value) => value === this.high_confidence + this.medium_confidence + this.no_confidence;
},

validations: {
    nr_of_clauses_per_round: {
        required,
        minValue
    },
    high_confidence: {
        required
    },
    medium_confidence: {
        required
    },
    no_confidence: {
        required
    }
},
Beusebiu
  • 1,433
  • 4
  • 23
  • 68
  • did you check and ensure all value is Number type? if they treated as string, it may not add up mathematically – Jake Lam May 20 '20 at 06:43
  • all of them are "type="number" ,PS. I am using Bootstrap-Vue, but I don't think that matters. – Beusebiu May 20 '20 at 06:44

1 Answers1

1

You should import { sameAs } from Vuelidate too, and add a validation sameAs([your field]), like that.

Please read the doc: https://vuelidate.js.org/#sub-contextified-validators

Etienne Bender
  • 326
  • 1
  • 5