I have collected data related to various businesses:
{
"business": {
"type": [
"LLC",
"Corporation"
],
"LLC": {
"status": "active",
"profits": 1000000,
"period": "yearly"
},
"corporation": {},
"partnership": {}
}
}
I am seeking advice on how to validate the "corporation" object. I want to ensure that if the "type" array includes the string "Corporation", then the "corporation" object must not be empty.
Although I attempted using validate.js to check for emptiness, it does not allow me to specifically target the strings within the type array for validation.
const validate = require('validate.js');
if (validate.isEmpty(business.LLC)) {
return wrapper.error('fail', 'Object is empty');
}
Your assistance on this matter would be greatly appreciated 🙏🏻