feat: add slider range validation
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
parent
0305f0be15
commit
36c87e4ad6
1 changed files with 11 additions and 0 deletions
|
|
@ -41,6 +41,17 @@ export function validateForm(
|
|||
errors.push({ fieldId: field.id, message: `${field.label} must be between 1 and 5.` });
|
||||
}
|
||||
}
|
||||
if (field.type === 'slider') {
|
||||
const n = Number(value);
|
||||
const min = field.min ?? 0;
|
||||
const max = field.max ?? 100;
|
||||
if (isNaN(n) || n < min || n > max) {
|
||||
errors.push({
|
||||
fieldId: field.id,
|
||||
message: `${field.label} must be between ${min} and ${max}.`,
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue