mirror of
https://github.com/pterodactyl/panel.git
synced 2026-11-30 11:25:52 -05:00
17 lines
486 B
TypeScript
17 lines
486 B
TypeScript
type TextValidator = ({ value }: { value: string }) => string | undefined;
|
|
|
|
/** A text field validator that requires a value no longer than `max` characters. */
|
|
export const requiredWithMaxLength =
|
|
(max: number, missing: string, tooLong: string): TextValidator =>
|
|
({ value }): string | undefined => {
|
|
if (value.length < 1) {
|
|
return missing;
|
|
}
|
|
|
|
if (value.length > max) {
|
|
return tooLong;
|
|
}
|
|
|
|
return undefined;
|
|
};
|