more variety of presence check

This commit is contained in:
Cássio Zen 2017-01-16 16:51:53 -02:00
parent e51b098fef
commit 63ae669507

View File

@ -41,7 +41,12 @@ class ControlHOC extends Component {
validatePresence(field, value) {
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: false };