matt bin Fri Apr 29 15:40:06 -0400 2011

Subject: Using null

Hi I would like to use the validates_format_of validator and make it check not only the regex I give it but allow for null values aswell now in the wiki it says it should allow a parameter called allow_null or allow_blank yet I don't see any implementations of these in the docs..
could u guys give me an example... tnx

matt bin Fri Apr 29 17:15:55 -0400 2011

ok I figured it out :D
static $validates_format_of = array
array('capital_id', 'with' =>'/^([0-9_-])$/i','allow_null' => TRUE),

Yoan B Sat Apr 30 07:32:46 -0400 2011

Shouldn't you escape the dash? And i isn't necessary since you have not characters that are case sensitive.

1 static $validates_format_of = array(
2     array('capital_id', 'with' => '/^([0-9_\-])$/', 'allow_null' => true),
3 );
matt bin Sat Apr 30 07:41:36 -0400 2011

ok, nice one Yoan.
Tnx for the help:)