File tree 2 files changed +16
-0
lines changed
2 files changed +16
-0
lines changed Original file line number Diff line number Diff line change @@ -118,6 +118,12 @@ public function isValid($value)
118
118
return true ;
119
119
}
120
120
121
+ if ($ value === '' ) {
122
+ $ this ->error (self ::NOT_FLOAT );
123
+
124
+ return false ;
125
+ }
126
+
121
127
// Need to check if this is scientific formatted string. If not, switch to decimal.
122
128
$ formatter = new NumberFormatter ($ this ->getLocale (), NumberFormatter::SCIENTIFIC );
123
129
Original file line number Diff line number Diff line change @@ -217,4 +217,14 @@ public function testNotFloat(): void
217
217
$ message = $ this ->validator ->getMessages ();
218
218
self ::assertStringContainsString ('does not appear to be a float ' , $ message ['notFloat ' ]);
219
219
}
220
+
221
+ public function testEmptyStringShouldReturnStandardErrorMessage (): void
222
+ {
223
+ self ::assertFalse ($ this ->validator ->isValid ('' ));
224
+ $ message = $ this ->validator ->getMessages ();
225
+ self ::assertStringContainsString (
226
+ 'does not appear to be a float ' ,
227
+ $ message ['notFloat ' ]
228
+ );
229
+ }
220
230
}
You can’t perform that action at this time.
0 commit comments