fix: Fixed bug when currency with 4 letters did not pass validation
This commit is contained in:
parent
d3027506a6
commit
62e42cf12a
1 changed files with 6 additions and 4 deletions
|
@ -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({
|
||||||
|
|
Loading…
Add table
Reference in a new issue