From 5dcdb2dcb8f7e2625a7b0a00041eda8a6fd2f405 Mon Sep 17 00:00:00 2001 From: Andrew Kingston Date: Fri, 10 Sep 2021 14:30:10 +0100 Subject: [PATCH] Update validation so that 'minimum' and 'minimum length' contraints both accept null values --- packages/client/src/components/app/forms/validation.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/packages/client/src/components/app/forms/validation.js b/packages/client/src/components/app/forms/validation.js index deb228c4c0..3bcf551bb0 100644 --- a/packages/client/src/components/app/forms/validation.js +++ b/packages/client/src/components/app/forms/validation.js @@ -224,7 +224,7 @@ const requiredHandler = value => { // Evaluates a min length constraint const minLengthHandler = (value, rule) => { const limit = parseType(rule.value, "number") - return value && value.length >= limit + return value == null || value.length >= limit } // Evaluates a max length constraint @@ -237,7 +237,7 @@ const maxLengthHandler = (value, rule) => { const minValueHandler = (value, rule) => { // Use same type as the value so that things can be compared const limit = parseType(rule.value, rule.type) - return value && value >= limit + return value == null || value >= limit } // Evaluates a max value constraint