Compare commits

...

2 Commits

Author SHA1 Message Date
p.belezov 58e25b7759 Вынес регулярку в файл с правилами 2024-10-29 14:35:59 +08:00
p.belezov 970412b736 Фикс регулярки 2024-10-29 14:31:26 +08:00
3 changed files with 5 additions and 2 deletions

View File

@ -11,5 +11,8 @@ export const rules = {
},
price: value => {
return (typeof value == 'number' || typeof value == 'undefined' || value === null) || 'Стоимость должна быть числом';
},
isNumber: value => {
return /^\d+[\.,\,]?\d*$/.test(value);
}
}

View File

@ -27,7 +27,7 @@ export default {
if (this.price == ''){
this.price = null;
}
if (typeof this.price == 'string' && /^\d+[\.,\,]?\d+$/.test(this.price)){
if (typeof this.price == 'string' && rules.isNumber(this.price)){
this.price = parseFloat(this.price)
}
let validateName = rules.notNull(this.name);

View File

@ -35,7 +35,7 @@ export default {
if (this.price == ""){
this.price = null;
}
if (typeof this.price == 'string' && /^\d+[\.,\,]?\d+$/.test(this.price)){
if (typeof this.price == 'string' && rules.isNumber(this.price)){
this.price = parseFloat(this.price)
}
let validateId = rules.id(this.wish_id);