Quantcast
Channel: Active questions tagged react-native+typescript - Stack Overflow
Viewing all articles
Browse latest Browse all 6287

React-Native check if mandatory fields are filled

$
0
0

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]);

Viewing all articles
Browse latest Browse all 6287

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>