From 05d6484a3382e08c33b5aabab090ad6ec0bea32e Mon Sep 17 00:00:00 2001 From: Jorge Padawan Date: Thu, 21 Jan 2021 10:48:25 +0100 Subject: [PATCH] Add message if BIC already exist --- modules/supplier/back/models/bank-entity.js | 11 +++++++ modules/supplier/back/models/bank-entity.json | 29 +++++++++++++++++++ 2 files changed, 40 insertions(+) create mode 100644 modules/supplier/back/models/bank-entity.js create mode 100644 modules/supplier/back/models/bank-entity.json diff --git a/modules/supplier/back/models/bank-entity.js b/modules/supplier/back/models/bank-entity.js new file mode 100644 index 000000000..565c27752 --- /dev/null +++ b/modules/supplier/back/models/bank-entity.js @@ -0,0 +1,11 @@ +module.exports = Self => { + Self.validatesPresenceOf('name', { + message: 'Name cannot be blank' + }); + Self.validatesPresenceOf('bic', { + message: 'Swift / BIC cannot be empty' + }); + Self.validatesUniquenessOf('bic', { + message: 'This BIC already exist.' + }); +}; diff --git a/modules/supplier/back/models/bank-entity.json b/modules/supplier/back/models/bank-entity.json new file mode 100644 index 000000000..c45cd4336 --- /dev/null +++ b/modules/supplier/back/models/bank-entity.json @@ -0,0 +1,29 @@ +{ + "name": "BankEntity", + "base": "VnModel", + "options": { + "mysql": { + "table": "bankEntity" + } + }, + "properties": { + "id": { + "type": "Number", + "id": true, + "description": "Identifier" + }, + "bic": { + "type": "String" + }, + "name": { + "type": "String" + } + }, + "relations": { + "country": { + "type": "belongsTo", + "model": "Country", + "foreignKey": "countryFk" + } + } +} \ No newline at end of file