refs #5837 if isSocialNameUnique
gitea/salix/pipeline/head There was a failure building this commit Details

This commit is contained in:
Carlos Satorres 2023-07-14 13:07:40 +02:00
parent 765c22df96
commit 93387cae62
1 changed files with 10 additions and 2 deletions

View File

@ -42,6 +42,14 @@ module.exports = Self => {
async function socialNameIsUnique(err, done) {
const filter = {
include: {
relation: 'country',
scope: {
fields: {
isSocialNameUnique: true,
},
},
},
where: {
and: [
{socialName: this.socialName},
@ -54,8 +62,8 @@ module.exports = Self => {
const existingClient = await Self.app.models.Client.findOne(filter);
if (existingClient) {
console.log(this.isSocialNameUnique);
if (!this.isSocialNameUnique && this.socialName === existingClient.socialName)
// eslint-disable-next-line max-len
if (existingClient.country().isSocialNameUnique && this.socialName === existingClient.socialName)
err();
}