Sunday, 23 April 2017

Node Js Express validator Check if field is empty or numeric

I use express-validator to check my post fields, one of my field must be a decimal or empty. I used this Schema:

request.checkBody({ 
        'product_price': {
            optional: true,
            isDecimal: {
                errorMessage: 'The product price must be a decimal'
            }
        }
})

The problem with this Schema is to not validate my post if product_price is empty, even with "optional: true".



via medKHELIFI

No comments:

Post a Comment