Add apply_array_filters for apply filters for array #1

Merged
ps merged 2 commits from a.prusov/metagen_php:master into master 2023-07-12 11:16:20 +03:00
Member

Что бы удовлетворить потребность в валидации размерности массива.

Например обязательной минимальной длины:

function arr_min_length($val, $name, $struct, $args)
{
  if(!is_array($val))
    throw new Exception("Field ".$name." is not array!");
  if(!is_numeric($args))
    throw new Exception("Wrong usage of \"arr_min_length\". Use \"@arr_min_length:1\" where 1 - length");
  if(count($val) < intval($args))
    throw new Exception("Wrong lenght (".count($val).") for \"".$name."\". Length must be equal or greater than ".$args);
  return $val;
}
Что бы удовлетворить потребность в валидации размерности массива. Например обязательной минимальной длины: ``` function arr_min_length($val, $name, $struct, $args) { if(!is_array($val)) throw new Exception("Field ".$name." is not array!"); if(!is_numeric($args)) throw new Exception("Wrong usage of \"arr_min_length\". Use \"@arr_min_length:1\" where 1 - length"); if(count($val) < intval($args)) throw new Exception("Wrong lenght (".count($val).") for \"".$name."\". Length must be equal or greater than ".$args); return $val; } ```
a.prusov added 1 commit 2023-07-11 19:25:25 +03:00
a.prusov added 1 commit 2023-07-11 20:42:22 +03:00
ps merged commit 2fc83c97b0 into master 2023-07-12 11:16:20 +03:00
Sign in to join this conversation.
No reviewers
No Label
No Milestone
No project
No Assignees
1 Participants
Notifications
Due Date
The due date is invalid or out of range. Please use the format 'yyyy-mm-dd'.

No due date set.

Dependencies

No dependencies set.

Reference: bit/metagen_php#1
No description provided.