Arrays 如何验证codeigniter中数组的值

Arrays 如何验证codeigniter中数组的值,arrays,codeigniter,validation,Arrays,Codeigniter,Validation,我正在使用codeigniter处理插入数据。 这是我得到的post数据数组 问题:我将应用软件ID,语言ID,工作日发送到我的HTML表单中,因此我在post中得到了它,如这里的post数组所示。但是codeigniter没有验证这三个值 如何验证这三个值代码点火器在验证后显示此错误。我不知道我怎么可能正确发送数据,但CI验证仍然没有得到它 应用程序ID字段是必需的 Langusge IDs字段是必需的 “工作日”字段是必填字段 这是我的帖子 Array ( [app_soft_ids

我正在使用
codeigniter
处理插入数据。 这是我得到的post数据数组

问题:我将
应用软件ID
语言ID
工作日
发送到我的HTML表单中,因此我在post中得到了它,如这里的post数组所示。但是
codeigniter
没有验证这三个值

如何验证这三个值<代码>代码点火器在验证后显示此错误。我不知道我怎么可能正确发送数据,但CI验证仍然没有得到它

应用程序ID字段是必需的

Langusge IDs字段是必需的

“工作日”字段是必填字段

这是我的帖子

Array
(
    [app_soft_ids] => Array
        (
            [0] => 66
            [1] => 68
        )

    [lang_ids] => Array
        (
            [0] => 4
            [1] => 5
        )
    [working_days] => Array
        (
            [0] => 4
        )

    [shift] => Y    
    [status] => O
    [expiry_date] => 10/07/2017
)
这是我的验证代码:

$config = array(
    'app_validation' => array(
        array(
                'field' => 'app_soft_ids',
                'label' => 'Application IDs',
                'rules' => 'required|numeric'
        ),
        array(
                'field' => 'lang_ids',
                'label' => 'Langusge IDs',
                'rules' => 'required|numeric'
        ),
        array(
                'field' => 'working_days',
                'label' => 'Working Days',
                'rules' => 'required|numeric'
        ),
        array(
                'field' => 'shift',
                'label' => 'Shift',
                'rules' => 'required|trim|max_length[1]|'
        )
    )
);

感谢kumar_v的评论,我得到了验证数组的方法,只需添加
[]
init即可

$config = array(
    'app_validation' => array(
        array(
                'field' => 'app_soft_ids[]',
                'label' => 'Application IDs',
                'rules' => 'required|numeric'
        ),
        array(
                'field' => 'lang_ids[]',
                'label' => 'Langusge IDs',
                'rules' => 'required|numeric'
        ),
        array(
                'field' => 'working_days[]',
                'label' => 'Working Days',
                'rules' => 'required|numeric'
        ),
        array(
                'field' => 'shift',
                'label' => 'Shift',
                'rules' => 'required|trim|max_length[1]|'
        )
    )
);

感谢kumar_v的评论,我得到了验证数组的方法,只需添加
[]
init即可

$config = array(
    'app_validation' => array(
        array(
                'field' => 'app_soft_ids[]',
                'label' => 'Application IDs',
                'rules' => 'required|numeric'
        ),
        array(
                'field' => 'lang_ids[]',
                'label' => 'Langusge IDs',
                'rules' => 'required|numeric'
        ),
        array(
                'field' => 'working_days[]',
                'label' => 'Working Days',
                'rules' => 'required|numeric'
        ),
        array(
                'field' => 'shift',
                'label' => 'Shift',
                'rules' => 'required|trim|max_length[1]|'
        )
    )
);

您正在使用数组数据类型的数字规则进行验证。检查此链接检查您正在使用数组数据类型的数字规则验证的答案。检查此链接检查此答案