Codeigniter的form_validation类中如何允许空值或数字值?

sun*_*tro 1 php validation codeigniter

我想使用form_validation类对输入进行验证,这将允许我在字段中输入数字或空值。
像这样:

$this->form_validation->set_rules('field[]','The field','numeric or empty|xss_clean');
Run Code Online (Sandbox Code Playgroud)

这有可能实现吗?

Sam*_*ger 6

$this->form_validation->set_rules('field[]', 'The field', 'numeric|xss_clean');
Run Code Online (Sandbox Code Playgroud)

从理论上讲,这应该足够了,因为该字段尚未设置为必填字段。