Files
pterodactyl-panel/resources/scripts/components/admin/numberInput.ts
T
6c0413e39b Start 2.0 development
Co-authored-by: Anthony <anthony@infraly.co>
Co-authored-by: Sky Mulley <daniel.mulley@outlook.com>
2026-10-05 18:10:18 -04:00

16 lines
512 B
TypeScript

/** `null` while the input is empty. */
export type NumberInputValue = number | null;
export const requiredNumber =
(message: string, check?: (value: number) => string | undefined) =>
({ value }: { value: NumberInputValue }): string | undefined =>
value === null ? message : check?.(value);
export const submittedNumber = (value: NumberInputValue): number => {
if (value === null) {
throw new Error('A required number input was submitted while empty.');
}
return value;
};