Added message for duplicated names
gitea/salix/pipeline/head This commit looks good Details

This commit is contained in:
jorgebl 2021-03-05 08:45:14 +01:00
parent 5972526327
commit 63ac492845
4 changed files with 18 additions and 16 deletions

View File

@ -174,5 +174,7 @@
"That item doesn't exists": "Ese artículo no existe",
"There's a new urgent ticket": "Hay un nuevo ticket urgente: [{{title}}](https://cau.verdnatura.es/WorkOrder.do?woMode=viewWO&woID={{issueId}})",
"Invalid account": "Cuenta inválida",
"Compensation account is empty": "La cuenta para compensar está vacia"
"Compensation account is empty": "La cuenta para compensar está vacia",
"This genus already exist": "Este genus ya existe",
"This specie already exist": "Esta especie ya existe"
}

View File

@ -1,9 +1,9 @@
module.exports = Self => {
Self.validatesPresenceOf('name', {
message: 'Name cannot be blank'
});
let UserError = require('vn-loopback/util/user-error');
Self.validatesUniquenessOf('id', {
message: 'This name already exist.'
module.exports = Self => {
Self.rewriteDbError(function(err) {
if (err.code === 'ER_DUP_ENTRY')
return new UserError(`This genus already exist`);
return err;
});
};

View File

@ -0,0 +1,9 @@
let UserError = require('vn-loopback/util/user-error');
module.exports = Self => {
Self.rewriteDbError(function(err) {
if (err.code === 'ER_DUP_ENTRY')
return new UserError(`This specie already exist`);
return err;
});
};

View File

@ -1,9 +0,0 @@
module.exports = Self => {
Self.validatesPresenceOf('name', {
message: 'Name cannot be blank'
});
Self.validatesUniquenessOf('id', {
message: 'This name already exist.'
});
};