X-Git-Url: https://git.arvados.org/arvados-workbench2.git/blobdiff_plain/a971f4746874e85731cf4b27d850e7a16cd1bdb7..9e6253c3521b67d74acc7a715c4a7fdd8e8a700a:/src/validators/min.tsx

diff --git a/src/validators/min.tsx b/src/validators/min.tsx
new file mode 100644
index 00000000..e326a708
--- /dev/null
+++ b/src/validators/min.tsx
@@ -0,0 +1,12 @@
+// Copyright (C) The Arvados Authors. All rights reserved.
+//
+// SPDX-License-Identifier: AGPL-3.0
+
+import { isNumber } from 'lodash';
+
+export const ERROR_MESSAGE = (minValue: number) => `Minimum value is ${minValue}`;
+
+export const min =
+    (minValue: number, errorMessage = ERROR_MESSAGE) =>
+        (value: any) =>
+            isNumber(value) && value >= minValue ? undefined : errorMessage(minValue);
