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
    }
},
2
  • did you check and ensure all value is Number type? if they treated as string, it may not add up mathematically Commented May 20, 2020 at 6:43
  • all of them are "type="number" ,PS. I am using Bootstrap-Vue, but I don't think that matters. Commented May 20, 2020 at 6:44

1 Answer 1

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

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.