mirror of
https://github.com/pterodactyl/panel.git
synced 2026-11-30 11:25:52 -05:00
Co-authored-by: Anthony <anthony@infraly.co> Co-authored-by: Sky Mulley <daniel.mulley@outlook.com>
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;
|
|
};
|