How to pass array of string as params to cloud function?

Here is my cloud function :
Moralis.Cloud.define(‘search’, async (request) => {
try {
const response = await search(request.params);
return { code: 200, status: true, data: response };
} catch (error) {
saveLogs(error.message, LOG_TYPE.ERROR);
return { code: 500, status: false, error: error.message };
}
}, searchValidationObject);

Here is my searchValidationObject :
const searchValidationObject = {
fields: {
country: {
required: true,
type: Array,
options: (val) => {
return isCountrySupported(val)
},
error: “country is invalid or not supported”,
},
},
requireUser: true,
requireUserKeys: [“sessionToken”, “ethAddress”]
}

This is how I am calling cloud function:
let params = {
country: [‘india’],
limit: 10,
skip: 0
}

try {
const result = await Moralis.Cloud.run(‘search’, params);
console.log(result);
} catch (error) {
console.error(error.message);
console.error(error);
}

Giving error
Parse error: Validation failed. Invalid type for country. Expected: array

You could add some logging to see what was received in that function. You could also try with different parameters like an array of 2 elements in case that you need to change the syntax for on element.

You can also do the validation separately in flyer function code

ERROR || 2022-03-07 14:45:38
Failed running cloud function search for user undefined with:
Input: {“country”:[“india”],“limit”:10,“skip”:0}
Error: {“message”:“Validation failed. Invalid type for country. Expected: array”,“code”:142}

Try with two elements in that array

Same error:
ERROR || 2022-03-07 15:02:51
Failed running cloud function search for user undefined with:
Input: {“country”:[“india”,“usa”],“limit”:10,“skip”:0}
Error: {“message”:“Validation failed. Invalid type for country. Expected: array”,“code”:142}

What you get if you log type of that parameter?

we get typeof country as object

You could do your own validation, I don’t know why it says that it is object.