File tree 2 files changed +14
-2
lines changed
2 files changed +14
-2
lines changed Original file line number Diff line number Diff line change @@ -89,7 +89,7 @@ public function validateRecord(Doctrine_Record $record)
89
89
*/
90
90
public static function validateLength ($ value , $ type , $ maximumLength )
91
91
{
92
- if ($ maximumLength === null ) {
92
+ if ($ maximumLength === null || $ value === null ) {
93
93
return true ;
94
94
}
95
95
if ($ type == 'timestamp ' || $ type == 'integer ' || $ type == 'enum ' ) {
Original file line number Diff line number Diff line change @@ -123,7 +123,19 @@ public function testIsValidType()
123
123
$ this ->assertTrue (Doctrine_Validator::isValidType ($ var , 'object ' ));
124
124
}
125
125
126
- public function testValidate2 ()
126
+ public function testIsValidLength ()
127
+ {
128
+ // Test length is less than maximum length
129
+ $ this ->assertTrue (Doctrine_Validator::validateLength (1.2345 , "decimal " , 5 ));
130
+
131
+ // Test null value is less than maximum length
132
+ $ this ->assertTrue (Doctrine_Validator::validateLength (null , "decimal " , 4 ));
133
+
134
+ // Test length is greater than maximum length
135
+ $ this ->assertFalse (Doctrine_Validator::validateLength (1.2345 , "decimal " , 4 ));
136
+ }
137
+
138
+ public function testValidate2 ()
127
139
{
128
140
$ test = new ValidatorTest ();
129
141
$ test ->mymixed = "message " ;
You can’t perform that action at this time.
0 commit comments