Validator Example
ktalai - September 25, 2008 - 23:46
| Project: | Validation API |
| Version: | 6.x-1.0-rc2 |
| Component: | Documentation |
| Category: | support request |
| Priority: | normal |
| Assigned: | Unassigned |
| Status: | closed |
Jump to:
Description
Hello,
I'd appreciate a simple PHP validator example to just make clear what the module expects to see. I am trying to validate against blank field have tried the following guess snippets and none is working:
$value != ''
and
if (!$value) return false;
and
if ($value == '') form_set_error();
Thanks,
KT

#1
Well, I created a validator like this to check if a field has any value in it:
return !empty($value);
It seemed to work fine. However when you are applying a field that will be validated using that validator, "Allow this field to be empty?" MUST NOT be checked, or else your validator will never fail.
#2
Automatically closed -- issue fixed for two weeks with no activity.