Fix presence validation for array values

This commit is contained in:
Andrew Kingston 2021-02-02 13:50:13 +00:00
parent 7c0a2bc2f5
commit 7984382552
1 changed files with 7 additions and 1 deletions

View File

@ -58,7 +58,13 @@ export const createValidatorFromConstraints = (constraints, field, table) => {
} }
const presenceConstraint = value => { 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 => { const lengthConstraint = maxLength => value => {