auraphp/Aura.Filter

best way to validate each item in array

Closed this issue · 2 comments

Say I have a $subject like this:

$subject = [
  'field' => 'value'
  'array_field' => [
    1,
    2
  ]
];

What is the best way to create a $filter that will ensure that field is a string and that array_field only contains integers?

Currently I'm using a custom callback function. Is there a better way?

Your callback is likely the best solution currently. #117 has some discussion on dealing with arrays as properties of subjects in various ways. Also, #131 has some attempt to start actually addressing it.

ah cool. I think this can be closed then.