From 62e42cf12a9ccdc115c0fa8092bb04a64c254c73 Mon Sep 17 00:00:00 2001 From: Redume Date: Fri, 11 Apr 2025 23:52:02 +0300 Subject: [PATCH] fix: Fixed bug when currency with 4 letters did not pass validation --- models/Currency.js | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/models/Currency.js b/models/Currency.js index 803dd08..b146417 100644 --- a/models/Currency.js +++ b/models/Currency.js @@ -1,14 +1,16 @@ const Joi = require('joi'); const currencySchema = Joi.object({ - from_currency: Joi.string().length(3).required().messages({ + from_currency: Joi.string().min(3).max(4).required().messages({ 'string.base': 'from_currency must be a string', - 'string.length': 'from_currency must be exactly 3 characters long', + 'string.min': 'from_currency must be at least 3 characters long', + 'string.max': 'from_currency must be no more than 4 characters long', 'any.required': 'from_currency is required' }), - conv_currency: Joi.string().length(3).required().messages({ + conv_currency: Joi.string().min(3).max(4).required().messages({ 'string.base': 'conv_currency must be a string', - 'string.length': 'conv_currency must be exactly 3 characters long', + 'string.min': 'conv_currency must be at least 3 characters long', + 'string.max': 'conv_currency must be no more than 4 characters long', 'any.required': 'conv_currency is required' }), date: Joi.date().iso().required().messages({