Merge pull request #11713 from strapi/v4/fix-unique-on-publish

Pass entity down to the validatCreation for publish and handle undefined value
This commit is contained in:
Alexandre BODIN 2021-11-29 20:06:26 +01:00 committed by GitHub
commit de7e2ebb52
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 7 additions and 2 deletions

View File

@ -212,7 +212,12 @@ module.exports = ({ strapi }) => ({
}
// validate the entity is valid for publication
await strapi.entityValidator.validateEntityCreation(strapi.getModel(uid), entity);
await strapi.entityValidator.validateEntityCreation(
strapi.getModel(uid),
entity,
undefined,
entity
);
const data = { ...body, [PUBLISHED_AT_ATTRIBUTE]: new Date() };

View File

@ -127,7 +127,7 @@ const addUniqueValidator = (validator, { attr, model, updatedAttribute, entity }
* If the attribute value is `null` we want to skip the unique validation.
* Otherwise it'll only accept a single `null` entry in the database.
*/
if (updatedAttribute.value === null) {
if (_.isNil(updatedAttribute.value)) {
return true;
}