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
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

TapocoL - September 29, 2008 - 15:18
Status:active» fixed

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

Anonymous (not verified) - October 13, 2008 - 15:22
Status:fixed» closed

Automatically closed -- issue fixed for two weeks with no activity.

 
 

Drupal is a registered trademark of Dries Buytaert.