Валидация данных при отправке Axios во Vue компоненте
подскажите пожалуйста у меня есть метод отправки формы данных через axios:
sendForm() {
if (false) {
const claimNumId = window.location.search.replace(/[^0-9]/g, "");
axios({
method: "post",
url: "/ajax/qsnnr/save/",
data: {
"claimNum": claimNumId,
"questions": [
{
"name": '121',
"value": this.inputValues.questionValue1
},
{
"name": '122',
"value": this.inputValues.questionValue2
},
{
"name": '123',
"value": this.inputValues.questionValue3
},
{
"name": '124',
"value": this.inputValues.comment
},
{
"name": '125',
"value": this.inputValues.comment2
}
],
status: 1,
},
headers: {"X-Requested-With": "XMLHttpRequest"},
})
.then(function (response) {
console.log(response);
})
.catch(function (response) {
console.log(response);
});
} else {
// тут реализовать проверку
}
},
Задача заключается в том, что бы если одно из значений value является пустым, то запретить отправку формы.

Ответы (1 шт):
Автор решения: Sanya H
→ Ссылка
const questions = [
{
"name": '121',
"value": this.inputValues.questionValue1
},
{
"name": '122',
"value": this.inputValues.questionValue2
},
{
"name": '123',
"value": this.inputValues.questionValue3
},
{
"name": '124',
"value": this.inputValues.comment
},
{
"name": '125',
"value": this.inputValues.comment2
}
];
...
if (!questions.some(el => el.value === '')) {
//отправляем запрос