diff --git a/src/validations/extendedApi.validation.js b/src/validations/extendedApi.validation.js index 5a7bdd8..7e44799 100644 --- a/src/validations/extendedApi.validation.js +++ b/src/validations/extendedApi.validation.js @@ -29,8 +29,16 @@ const createExtendedApi = { ), isWishlist: Joi.boolean().default(false), unit: Joi.string().allow('', null), - min: Joi.number(), - max: Joi.number(), + min: Joi.number().when('datatype', { + is: 'float', + then: Joi.number().unsafe(), + otherwise: Joi.number().integer() + }), + max: Joi.number().when('datatype', { + is: 'float', + then: Joi.number().unsafe(), + otherwise: Joi.number().integer() + }), allowed: Joi.array().items(Joi.any()), comment: Joi.string(), default: Joi.any(), @@ -80,8 +88,16 @@ const updateExtendedApi = { ), isWishlist: Joi.boolean(), unit: Joi.string().allow('', null), - min: Joi.number(), - max: Joi.number(), + min: Joi.number().when('datatype', { + is: 'float', + then: Joi.number().unsafe(), + otherwise: Joi.number().integer() + }), + max: Joi.number().when('datatype', { + is: 'float', + then: Joi.number().unsafe(), + otherwise: Joi.number().integer() + }), allowed: Joi.array().items(Joi.any()), comment: Joi.string(), default: Joi.any(),