fix: Fixed bug when currency with 4 letters did not pass validation

This commit is contained in:
Danil 2025-04-11 23:52:02 +03:00
parent d3027506a6
commit 62e42cf12a

View file

@ -1,14 +1,16 @@
const Joi = require('joi'); const Joi = require('joi');
const currencySchema = Joi.object({ 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.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' '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.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' 'any.required': 'conv_currency is required'
}), }),
date: Joi.date().iso().required().messages({ date: Joi.date().iso().required().messages({