Hello List!
My problem is that i am sending a long enough string (12345 and 123456789, see
below), but i always get NOT_BETWEEN
I am new to ZF but i am trying to do my best getting this to work. I am using
ZendFramework 1.0.1
Please check out the following three snippets and help me out.
Thank you
--------------
SETUP
$filters = array(
'*' => array('StringTrim', 'StripTags'),
'id' => 'Digits',
'page' => 'Alpha'
);
$validators = array(
'username' => array(
new Zend_Validate_Alnum(),
new Zend_Validate_Between(4, 30),
'breakChainOnFailure' => true,
'messages' => array(
0 => array(
Zend_Validate_Alnum::STRING_EMPTY => 'Please enter your username in the
field below.',
Zend_Validate_Alnum::NOT_ALNUM => 'Usernames may only contain numbers and
letters, without spaces.'
),
1 => array(
Zend_Validate_Between::NOT_BETWEEN => '%value% - Usernames must be
between %min% and %max% characters.'
)
)
),
'password' => array(
new Zend_Validate_Alnum(),
new Zend_Validate_Between(8, 30),
'breakChainOnFailure' => true,
'messages' => array(
0 => array(
Zend_Validate_Alnum::STRING_EMPTY => 'Please enter your password in the
field below.',
Zend_Validate_Alnum::NOT_ALNUM => 'Passwords may only contain numbers and
letters, without spaces.'
),
1 => array(
Zend_Validate_Between::NOT_BETWEEN => '%value% - Passwords must be
between %min% and %max% characters.'
)
)
)
);
$options = array(
'allowEmpty' => false,
'breakChainOnFailure' => false,
'escapeFilter' => 'HtmlEntities',
'missingMessage' => 'Field %field% is required by rule %rule%, but the
field is missing',
'notEmptyMessage' => 'You must give a non-empty value for field %field%',
'presence' => 'optional'
);
$input_data = array_merge_recursive($_POST, $_GET); // combine
$this->input = new Zend_Filter_Input($filters, $validators, $input_data,
$options);
--------------
TEST
if ($this->input->hasInvalid() || $this->input->hasMissing()) {
$messages = $this->input->getMessages();
Zend_Debug::Dump($messages);
}
--------------
OUTPUT, after sending a 5 char long string and 9 char long string
array(2) {
["username"] => array(1) {
[0] => string(54) "12345 - Usernames must be between 4 and 30 characters."
}
["password"] => array(1) {
[0] => string(58) "123456789 - Passwords must be between 8 and 30
characters."
}
}As you can see by the output, it doesn't even make sense out of itself.
Something weird is going on here .. Thanks for your time!