// @param obj: for which the given properties exist
// @param fields[]: is an array of given object properties
// @return false if every field is not blank
// @return an array of labels that are blank
const checkCompulsoryFields = (obj: any, fields: string[]): boolean | string[] => {
const list = fields.filter(field => field in obj && obj[field].trim() === "")
return list.length === 0 ? false : list
}
Last active
March 23, 2021 06:38
-
-
Save mudssrali/f1be8be48d6d8933a88db412510c9edf to your computer and use it in GitHub Desktop.
check compulsory fields in an object
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment