I am implementing JOI validation and want to validate comma separated string by JOI. This string contain only particular text string like ‘admin’,’client’, ‘customer’, ‘user’. For example check below. I can validate this by JavaScript, but i want to validate by JOI
function checkString(perm)
{
const a = ['admin','client', 'customer', 'user'];
const check = perm.split(",");
if(!check.every(val => a.includes(val)))
{
return false;
}
return true;
}
//alert(checkString('admin,client,customer')) //true
//alert(checkString('customer')) //true
//alert(checkString('admin,client,buyer')) //false
//alert(checkString('buyer')) //false
//alert(checkString('admin,client,customer,buyer')) //false