Using express-jsonschema
How to validation two fields, for example:
("quantity" == 0 && "actualQuantity" == 0) || ("quantity" > 0 && "actualQuantity" > 0)
Just tested, this will do the job:
{
    "anyOf" : [
        {
            "properties" : {
                "quantity" : {
                    "minimum" : 0,
                    "maximum" : 0
                },
                "actualQuantity" : {
                    "minimum" : 0,
                    "maximum" : 0
                }
            }
        },
        {
            "properties" : {
                "quantity" : {
                    "minimum" : 1
                },
                "actualQuantity" : {
                    "minimum" : 1
                }
            }
        }
    ]
}
You could also use "oneOf" instead of "anyOf", but "anyOf" is faster with most implementations.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With