more variety of presence check
This commit is contained in:
parent
e51b098fef
commit
63ae669507
@ -41,7 +41,12 @@ class ControlHOC extends Component {
|
|||||||
|
|
||||||
validatePresence(field, value) {
|
validatePresence(field, value) {
|
||||||
const isRequired = field.get('required', true);
|
const isRequired = field.get('required', true);
|
||||||
if (isRequired && (value === null || value.length === 0)) {
|
if (isRequired && (
|
||||||
|
value === null ||
|
||||||
|
value === undefined ||
|
||||||
|
(value.hasOwnProperty('length') && value.length === 0) ||
|
||||||
|
(value.constructor === Object && Object.keys(value).length === 0)
|
||||||
|
)) {
|
||||||
return { error: true };
|
return { error: true };
|
||||||
}
|
}
|
||||||
return { error: false };
|
return { error: false };
|
||||||
|
Loading…
x
Reference in New Issue
Block a user