I have a class called person which has a lot of fields I am registering a new user in my application and I am trying to see if all mandatory fields are filled, the fields are, first_name, last_name, phone number etc... but this code below expects all fields to be filled I guess, I just want to check the fields with the names given below, hope someone can help
useEffect(() => { const checkMandatoryFields = Object.keys(person).every(field => { if ( field == 'first_name' || field == 'last_name' || field == 'phone' || field == 'plate' || field == 'brand' || field == 'model' || field == 'password' ) return true; return !!person[field]; }); setDisableSubmit(!checkMandatoryFields); }, [person]);