Fix presence validation for array values
This commit is contained in:
parent
17ad44369c
commit
3faef71ff4
|
@ -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 => {
|
||||||
|
|
Loading…
Reference in New Issue