I have a need to set a property on a plugin Model that is an array of one or more valid values.
I can see that I can use AttributeType::Enum and record and define a set of values but if I'm not mistaken, that enables me to validate a single value against that set of values:
class MyModel extends BaseModel
{
protected function defineAttributes()
{
return [
'mySetting' => [ AttributeType::Enum, 'values' => 'validOption1,validOption2,validOption3' ]
];
}
}
What I want to do is enable mySetting to be an array that would be valid when set as an array containing any combination of the defined options:
MyModel::populateModel(['mySetting' => [
'validOption1'
]]); // is valid
MyModel::populateModel(['mySetting' => [
'validOption1',
'validOption3'
]]); // is valid
MyModel::populateModel(['mySetting' => [
'invalidOption',
'validOption3'
]]); // is *not* valid
MyModel::populateModel(['mySetting' => []); // is *not* valid
Etc.