My task involves filtering an array of allowedFields that corresponds to the keys in a JSON array created from a form.
Some fields obtained are not necessary for validation at this point, so I aim to compare the values in the JSON array with those in the allowedFields array.
JSON data received from form:
{"reference":"sdfsdfsdfsd",
"start_date":"04/22/2014",
"end_date":"05//2014",
"status":"1","frequency":"M",
"day":"sat",
"contract_type":"S",
"notice_period":"1M"}
allowedFields = array(
reference,
start_date,
end_date,
contract_type
)
In essence, my goal is to remove any fields that are not included in the allowedFields JavaScript array.