Joi required 2 input validation

Viewed 105

I want to validate a currency entry that has only two fields (currency and info). currency is number and text field input is string. If the currency is different from 0.00, the information must be mandatory. When currency (expenseAnaliz) is different "0.00" my validation works correctly, when currency is 0.00 it shouldn't validate but when it is 0,00 it validates

expenseAnaliz:Joi.number()
             .when('expenseInfoAnaliz',{is:Joi.number(),
                                        then: Joi.number().allow(0.00),
                                        otherwise:Joi.number().required().label('Analiz Harcama Detayı')}),
expenseInfoAnaliz:Joi.string().allow(null),
0 Answers
Related