15027: Fixes unused declarations errors.
[arvados-workbench2.git] / src / validators / max-length.tsx
1 // Copyright (C) The Arvados Authors. All rights reserved.
2 //
3 // SPDX-License-Identifier: AGPL-3.0
4
5 export const ERROR_MESSAGE = 'Maximum string length of this field is: ';
6 export const DEFAULT_MAX_VALUE = 60;
7
8 export const maxLength: any = (maxLengthValue = DEFAULT_MAX_VALUE, errorMessage = ERROR_MESSAGE) => {
9     return (value: string) => {
10         if (value) {
11             return  value && value.length <= maxLengthValue ? undefined : `${errorMessage || ERROR_MESSAGE} ${maxLengthValue}`;
12         }
13
14         return undefined;
15     };
16 };