svelte-object
Version:
A nested component Svelte 5 Runes pattern for structuring objects/arrays and their properties
14 lines (13 loc) • 391 B
JavaScript
export function isMax(e, max, setToMax) {
if (typeof e.value !== 'number' || max === undefined || max === null)
return;
const tooLarge = e.value > max;
if (!tooLarge)
return;
if (setToMax) {
e.value = max;
e.warning(`Value must be less than or equal to ${max}`);
}
else
e.error(`Value must be less than or equal to ${max}`);
}