Вынес регулярку в файл с правилами
This commit is contained in:
		
							parent
							
								
									970412b736
								
							
						
					
					
						commit
						58e25b7759
					
				|  | @ -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); | ||||
|     } | ||||
| } | ||||
|  |  | |||
|  | @ -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); | ||||
|  |  | |||
|  | @ -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); | ||||
|  |  | |||
		Loading…
	
		Reference in New Issue