X-Git-Url: https://git.arvados.org/arvados-workbench2.git/blobdiff_plain/95716b93cba4651180021c9a5b752fa10cf5a301..f9dde5c781766b8be71d43d0f031c201a0edcfbb:/src/validators/min-length.tsx diff --git a/src/validators/min-length.tsx b/src/validators/min-length.tsx new file mode 100644 index 00000000..9b269531 --- /dev/null +++ b/src/validators/min-length.tsx @@ -0,0 +1,10 @@ +// Copyright (C) The Arvados Authors. All rights reserved. +// +// SPDX-License-Identifier: AGPL-3.0 + +export const ERROR_MESSAGE = (minLength: number) => `Min length is ${minLength}`; + +export const minLength = + (minLength: number, errorMessage = ERROR_MESSAGE) => + (value: { length: number }) => + value && value.length >= minLength ? undefined : errorMessage(minLength);