Ticket Details

Array support in Validator

RFC Ticket (closed)

Defining in a model:
{{{
public $validations = array(
    'field' => array('notEmpty'=>'Empty')
);
}}}

and using it with an array of strings (aimed at MongoDB usage):
{{{
$entity->field = array('foo', 'bar', '');
$entity->save();
}}}
does not work.

There are two issues in terms of operation:

1.  Returning bool is now ambigious, most likely needs change
2.  Needs to define if it is ok with 1 empty or if 1 mathcing is sufficient to pass

Possible definition:
{{{
'field' => array('notEmpty' => array('message' => 'Empty', 'threshold' => $int));
}}}
where 

* threshold = 1 = one matching is sufficient.
* threshold = 0 = all must match
* threshold = -1 = one failing is ok
on 11.02.10 reported by: Nervetattoo owned by: daschl

Updates

on 11.02.10 by Nervetattoo
[A validator implementation that allows you to use any validator on an array](http://pastium.org/view/556e1e359e5e3599de6f29f901ed971b)
(duplicate) on 07.04.11 by daschl
  • id was changed to 320
  • number was changed to 183
  • version was changed to lithium-0.9.5
  • owner was changed to daschl
  • type was changed to rfc
  • status was changed to closed
  • resolution was changed to duplicate
  • priority was changed to low
  • title was changed to Array support in Validator
  • description was changed
  • tags was changed to model, Validator
this ticket has been moved to github, thanks for the ticket! Feel free to add comments/suggestions there.

https://github.com/UnionOfRAD/lithium/issues/22