mirror of
https://github.com/strapi/strapi.git
synced 2025-12-27 15:13:21 +00:00
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:
commit
de7e2ebb52
@ -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() };
|
||||
|
||||
|
||||
@ -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;
|
||||
}
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user