I want to do the validation of form in my react application with Formik. I have the fields firstName, lastname, email, phone, address, hobbies. for firstName & lastName (both are required fields) intial values are
"firstName": "",
"lastName": "",
for rest of the fields (optional fields), initial values are
"infoFields": [
{
"fieldType": "",
"dataType": "",
"fieldValue": "",
"isPublic": false
}
]
Note:- isPublic is a flag for the toggle button to show the field information to other users. So after filling the phone number, address, hobbies, the value should be like this
"infoFields": [
{
"fieldType": "PhoneNumber",
"dataType": "string",
"fieldValue": "+1234567890",
"isPublic": true
},
{
"fieldType": "Address",
"dataType": "string",
"fieldValue": "honolulu",
"isPublic": false
},
{
"fieldType": "Hobbies",
"dataType": "ObjectList",
"fieldValue": [ "cricket", "listening music" ],
"isPublic": false
},
.....................
]
How can we get this formik value on click of submit button to send these data to API.