Merge pull request #2588 from Budibase/fix-minimum-validation

Update minimum validation to accept nulls
This commit is contained in:
Andrew Kingston 2021-09-13 11:40:51 +01:00 committed by GitHub
commit 41f09f1907
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 2 additions and 2 deletions

View File

@ -224,7 +224,7 @@ const requiredHandler = value => {
// Evaluates a min length constraint // Evaluates a min length constraint
const minLengthHandler = (value, rule) => { const minLengthHandler = (value, rule) => {
const limit = parseType(rule.value, "number") const limit = parseType(rule.value, "number")
return value && value.length >= limit return value == null || value.length >= limit
} }
// Evaluates a max length constraint // Evaluates a max length constraint
@ -237,7 +237,7 @@ const maxLengthHandler = (value, rule) => {
const minValueHandler = (value, rule) => { const minValueHandler = (value, rule) => {
// Use same type as the value so that things can be compared // Use same type as the value so that things can be compared
const limit = parseType(rule.value, rule.type) const limit = parseType(rule.value, rule.type)
return value && value >= limit return value == null || value >= limit
} }
// Evaluates a max value constraint // Evaluates a max value constraint