I want to validate the object so that the object is not null and few of the fields in that object is not empty.
For example, consider the following object:
address ={
block : '2134',
street : 'berly street',
county : 'someCountry'
postal : '876546'
}
I am using es6. I found the solution to do this using lodash
I want to do this in plain JS. Please let me know if there is a better way to do this than below:
const isValidAddress = (address) => {
const addressFields = ['block', 'county', 'postal', 'street'];
return addressFields.every((element) => address[element] && address[element].length > 0);
};