Răsfoiți Sursa

Change validation errors to display in all caps

Lee Morgan 5 ani în urmă
părinte
comite
769762e0a4
1 a modificat fișierele cu 13 adăugiri și 13 ștergeri
  1. 13 13
      controllers/validator.js

+ 13 - 13
controllers/validator.js

@@ -3,17 +3,17 @@ const Merchant = require("../models/merchant.js");
 module.exports = {
     merchant: async function(merchant){
         if(!this.isSanitary([merchant.name])){
-            return "Name contains illegal characters";
+            return "NAME CONTAINS ILLEGAL CHARACTERS";
         }
 
         if(!/^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,3})+$/.test(merchant.email)){
-            return "Invalid email address";
+            return "INVALID EMAIL ADDRESS";
         }
 
         let checkMerchant = await Merchant.findOne({email: merchant.email});
 
         if(checkMerchant){
-            return "An account with that email address already exists";
+            return "AN ACCOUNT WITH THAT EMAIL ADDRESS ALREADY EXISTS";
         }
 
         let checkPassword = this.password(merchant.password, merchant.confirmPassword);
@@ -26,11 +26,11 @@ module.exports = {
 
     password: function(password, confirmPassword){
         if(password.length < 10){
-            return "Password must contain at least 10 characters";
+            return "PASSWORD MUST CONTAIN AT LEAST 10 CHARACTERS";
         }
 
         if(password !== confirmPassword){
-            return "Passwords do not match";
+            return "PASSWORDS DO NOT MATCH";
         }
 
         return true;
@@ -38,11 +38,11 @@ module.exports = {
 
     quantity: function(num){
         if(isNaN(num) || num === ""){
-            return "Quantity must be a number";
+            return "QUANTITY MUST BE A NUMBER";
         }
 
         if(num < 0){
-            return "Quantity cannot be a negative number";
+            return "QUANTITY CANNOT BE A NEGATIVE NUMBER";
         }
 
         return true;
@@ -50,11 +50,11 @@ module.exports = {
 
     price: function(price){
         if(price < 0){
-            return "Price cannot be a negative number";
+            return "PRICE CANNOT BE A NEGATIVE NUMBER";
         }
 
         if(isNaN(price) || price === ""){
-            return "Price must be a number";
+            return "PRICE MUST BE A NUMBER";
         }
 
         return true;
@@ -72,7 +72,7 @@ module.exports = {
     */
     ingredient: function(ingredient){
         if(!this.isSanitary([ingredient.name, ingredient.category])){
-            return "Ingredient contains illegal characters";
+            return "INGREDIENT CONTAINS ILLEGAL CHARACTERS";
         }
 
         if(ingredient.specialUnit === "bottle"){
@@ -87,7 +87,7 @@ module.exports = {
 
     recipe: function(recipe){
         if(!this.isSanitary([recipe.name])){
-            return "Ingredient contains illegal characters";
+            return "INGREDIENT CONTAINS ILLEGAL CHARACTERS";
         }
 
         let priceCheck = this.price(recipe.price);
@@ -115,11 +115,11 @@ module.exports = {
 
     order: function(order){
         if(!this.isSanitary([order.name])){
-            return "Order name contains illegal characters";
+            return "ORDER NAME CONTAINS ILLEGAL CHARACTERS";
         }
 
         if(new Date(order.date) > new Date()){
-            return "Date cannot be in the future";
+            return "DATE CANNOT BE IN THE FUTURE";
         }
 
         if(this.quantity(order.taxes) !== true){