mirror of
https://github.com/pterodactyl/panel.git
synced 2026-12-01 03:45:53 -05:00
16 lines
512 B
TypeScript
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;
|
||
|
|
};
|