UNPKG

vue-form-ui

Version:

A set of Vue form components with complex validation

35 lines 1.1 kB
export const validation = { data() { return { isValid: null, validationMessage: null, } }, methods: { setValidationStatus: function (resultsArray, isDate) { // check validation result if (resultsArray.every((data) => data == true)) { // if all array items equal true // validation passes this.isValid = true; this.validationMessage = "" } else { // if there is a validation false boolean // loop through and return the first error found for (let valCheck of resultsArray) { if (valCheck != true) { // set valid variable to false this.isValid = false; // set the error message to the message provided by validation this.validationMessage = valCheck.message // used to return the first date error // doesnt appear to be needed for other input types if (isDate !== undefined && isDate === true) { return } } } } } } }