Solved thread

This post is marked as solved. If you think the information contained on this thread must be part of the official documentation, please contribute submitting a pull request to its repository.

How to skip a validation if the form is empty?

Hi there, i am creating a validator for a number input. But, if the input is empty, it will still return true. How can i do it ?

The current code is like this :

$rank = new Text("rank");



new Numericality(array('message' => 'Rank must be a number'))


Thanks in advance :)


Use allowEmpty option

    new Numericality(array('message' => 'Rank must be a number', 'allowEmpty' => TRUE))

notice that 0 is an empty value


...I should have known that. Thanks :D