major refactor of web store into vue setup style declaration; reactivity debugging; order view has known refresh issues

This commit is contained in:
Tim Olson
2023-11-27 00:52:17 -04:00
parent 41457b85f5
commit d2db5dc4f7
24 changed files with 545 additions and 364 deletions

44
src/validate.js Normal file
View File

@@ -0,0 +1,44 @@
export function isEmpty(v) {
return v === null || typeof v === 'string' && v.trim() === ''
}
export function validateRequired(v) {
if (isEmpty(v))
return 'Required'
return true
}
export function validateAmount(v) {
if (isEmpty(v))
return true
const floatRegex = /^-?\d*(?:[.,]\d*?)?$/
if (!floatRegex.test(v))
return 'Amount must be a number'
if (parseFloat(v) <= 0)
return 'Amount must be positive'
return true
}
export function validateMax(v) {
if (!isEmpty(minPrice.value) && !isEmpty(v) && parseFloat(v) < parseFloat(minPrice.value))
return 'Must be greater than the minimum price'
return true
}
export function validateMin(v) {
if (!isEmpty(maxPrice.value) && !isEmpty(v) && parseFloat(v) > parseFloat(maxPrice.value))
return 'Must be less than the maximum price'
return true
}
export function validateTranches(v) {
const i = parseInt(v)
if (parseFloat(v) !== i)
return 'Whole numbers only'
if (i < 1)
return 'Must have at least one tranche'
if (i > 255)
return 'Maximum 255 tranches'
return true
}