Fix date and datetime required validations issue

Signed-off-by: soupette <cyril.lpz@gmail.com>
This commit is contained in:
soupette 2020-07-27 11:52:27 +02:00
parent e81c6ba567
commit b84e33ca47

View File

@ -9,6 +9,7 @@ import {
isNaN,
toNumber,
} from 'lodash';
import moment from 'moment';
import * as yup from 'yup';
import { translatedErrors as errorsTrads } from 'strapi-helper-plugin';
@ -285,6 +286,10 @@ const createYupSchemaAttribute = (type, validations, isCreatingEntry) => {
return !!value;
}
if (['date', 'datetime'].includes(type)) {
return moment(value)._isValid === true;
}
return !isEmpty(value);
});
}