From 4cc3fc90c5289d4572b1fae88d0f297f6c4d4000 Mon Sep 17 00:00:00 2001 From: jorgebl Date: Thu, 4 Mar 2021 21:30:56 +0100 Subject: [PATCH] conditionals if name already exists --- modules/item/back/models/genus.js | 9 +++++++++ modules/item/back/models/species.js | 9 +++++++++ modules/item/front/botanical/index.html | 1 - 3 files changed, 18 insertions(+), 1 deletion(-) create mode 100644 modules/item/back/models/genus.js create mode 100644 modules/item/back/models/species.js diff --git a/modules/item/back/models/genus.js b/modules/item/back/models/genus.js new file mode 100644 index 000000000..462d5efd4 --- /dev/null +++ b/modules/item/back/models/genus.js @@ -0,0 +1,9 @@ +module.exports = Self => { + Self.validatesPresenceOf('name', { + message: 'Name cannot be blank' + }); + + Self.validatesUniquenessOf('id', { + message: 'This name already exist.' + }); +}; diff --git a/modules/item/back/models/species.js b/modules/item/back/models/species.js new file mode 100644 index 000000000..462d5efd4 --- /dev/null +++ b/modules/item/back/models/species.js @@ -0,0 +1,9 @@ +module.exports = Self => { + Self.validatesPresenceOf('name', { + message: 'Name cannot be blank' + }); + + Self.validatesUniquenessOf('id', { + message: 'This name already exist.' + }); +}; diff --git a/modules/item/front/botanical/index.html b/modules/item/front/botanical/index.html index 79fc4dc9a..3d1beefd7 100644 --- a/modules/item/front/botanical/index.html +++ b/modules/item/front/botanical/index.html @@ -9,7 +9,6 @@