Skip to content

Commit

Permalink
Merge pull request strapi#11713 from strapi/v4/fix-unique-on-publish
Browse files Browse the repository at this point in the history
Pass entity down to the validatCreation for publish and handle undefined value
  • Loading branch information
alexandrebodin authored Nov 29, 2021
2 parents 56f0664 + 95935bb commit de7e2eb
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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() };

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

Expand Down

0 comments on commit de7e2eb

Please sign in to comment.