There's no strict requirement to use constants. You can use the literal
strings. I added constants in each of the other validators because it
aids developers who use tools with code-completion.
Regards,
Bill Karwin
________________________________
From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On
Behalf Of David Mintz
Sent: Wednesday, August 29, 2007 11:40 AM
To: [email protected]
Subject: [fw-general] extending Zend_Validate_Abstract
One question, before I set about extending
Zend_Validate_Abstract: In the example class definition given at
http://framework.zend.com/manual/en/zend.validate.writing_validators.htm
l :
const LENGTH
= 'length';
const UPPER
= 'upper';
const LOWER
= 'lower';
const DIGIT
= 'digit';
protected
$_messageTemplates = array(
self
::LENGTH => "'%value%' must be at least 8 characters in length"
,
self::UPPER
=> "'%value%' must contain at least one uppercase letter",
self::LOWER => "'%value%' must contain at least one lowercase
letter"
,
self::DIGIT
=> "'%value%' must contain at least one digit character"
);
I just wonder why you need the constants. No doubt this is a
standard design technique about which I am simply ignorant. But I'd like
to understand why you couldn't just have
protected $_messageTemplates
= array(
'length' => "'%value%' must be at least 8 characters in
length"
,
'upper' => "'%value%' must contain at least one
uppercase letter"
,
'lower'
=> "'%value%' must contain at least one lowercase letter",
'digit'
=> "'%value%' must contain at least one digit character"
);
--
David Mintz
http://davidmintz.org/
The subtle source is clear and bright
The tributary streams flow through the darkness