File tree Expand file tree Collapse file tree 3 files changed +9
-4
lines changed Expand file tree Collapse file tree 3 files changed +9
-4
lines changed Original file line number Diff line number Diff line change @@ -492,13 +492,18 @@ public function setEmpty() : static
492492 * Sets the object to values in the array. Invalid array values are ignored.
493493 *
494494 * @param array<string,mixed> $values
495- *
495+ * @param array<string> $allowedFields list of allowed field names, other fields names will be ignored. Empty array updates all valid fields.
496496 * @param bool $loaded set to true if you want to simulated being loaded from the db.
497497 */
498- public function setFrom (array $ values , bool $ loaded = false ) : static
498+ public function setFrom (array $ values , array $ allowedFields = [], bool $ loaded = false ) : static
499499 {
500500 $ this ->loaded = $ loaded ;
501501
502+ if (\count ($ allowedFields ))
503+ {
504+ $ values = \array_intersect_key ($ values , \array_flip ($ allowedFields ));
505+ }
506+
502507 foreach ($ values as $ field => $ value )
503508 {
504509 if (isset (static ::$ fields [$ field ]))
Original file line number Diff line number Diff line change @@ -48,7 +48,7 @@ public function next() : void
4848 }
4949 else
5050 {
51- $ this ->current ->setFrom ($ data , true );
51+ $ this ->current ->setFrom ($ data , loaded: true );
5252 }
5353 ++$ this ->index ;
5454 }
Original file line number Diff line number Diff line change 3232 *
3333 * | Validator Name | Description | Parameters |
3434 * | -------------- | ----------- | ----------- |
35- * | alnum | Numbers and characters only (ctype_alnum) | None |
35+ * | alpha_numeric | Numbers and characters only (ctype_alnum) | None |
3636 * | alpha | Characters only (ctype_alpha) | None |
3737 * | bool | Must be one or zero | None |
3838 * | card | Credit card number (LUHN validation) | None |
You can’t perform that action at this time.
0 commit comments