From 3faef71ff427259b019c9a071de94ba72c187530 Mon Sep 17 00:00:00 2001 From: Andrew Kingston Date: Tue, 2 Feb 2021 13:50:13 +0000 Subject: [PATCH] Fix presence validation for array values --- packages/standard-components/src/forms/validation.js | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/packages/standard-components/src/forms/validation.js b/packages/standard-components/src/forms/validation.js index bc09d1f95a..0bc926efa6 100644 --- a/packages/standard-components/src/forms/validation.js +++ b/packages/standard-components/src/forms/validation.js @@ -58,7 +58,13 @@ export const createValidatorFromConstraints = (constraints, field, table) => { } const presenceConstraint = value => { - return value == null || value === "" ? "Required" : null + let invalid + if (Array.isArray(value)) { + invalid = value.length === 0 + } else { + invalid = value == null || value === "" + } + return invalid ? "Required" : null } const lengthConstraint = maxLength => value => {