Files
pterodactyl-panel/resources/scripts/components/form/validators.ts
T
2026-10-08 18:49:15 -04:00

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;
};