@@ -2860,6 +2860,50 @@ public function testValidateDecimal()
28602860
28612861 $ v = new Validator ($ trans , ['foo ' => '1.88888888888888888888 ' ], ['foo ' => 'Decimal:20|Max:1.88888888888888888888 ' ]);
28622862 $ this ->assertTrue ($ v ->passes ());
2863+
2864+ $ v = new Validator ($ trans , [
2865+ // these are the same number
2866+ 'decimal ' => '0.555 ' ,
2867+ 'scientific ' => '5.55e-1 ' ,
2868+ ], [
2869+ 'decimal ' => 'Decimal:0,2 ' ,
2870+ 'scientific ' => 'Decimal:0,2 ' ,
2871+ ]);
2872+ $ this ->assertSame (['decimal ' , 'scientific ' ], $ v ->errors ()->keys ());
2873+
2874+ $ v = new Validator ($ trans , [
2875+ // these are the same number
2876+ 'decimal ' => '0.555 ' ,
2877+ 'scientific ' => '5.55e-1 ' ,
2878+ ], [
2879+ 'decimal ' => 'Decimal:0,3 ' ,
2880+ 'scientific ' => 'Decimal:0,3 ' ,
2881+ ]);
2882+ $ this ->assertSame (['scientific ' ], $ v ->errors ()->keys ());
2883+
2884+ $ v = new Validator ($ trans , ['foo ' => '+ ' ], ['foo ' => 'Decimal:0,2 ' ]);
2885+ $ this ->assertTrue ($ v ->fails ());
2886+ $ v = new Validator ($ trans , ['foo ' => '- ' ], ['foo ' => 'Decimal:0,2 ' ]);
2887+ $ this ->assertTrue ($ v ->fails ());
2888+ $ v = new Validator ($ trans , ['foo ' => '10@12 ' ], ['foo ' => 'Decimal:0,2 ' ]);
2889+ $ this ->assertTrue ($ v ->fails ());
2890+
2891+ $ v = new Validator ($ trans , ['foo ' => '+123 ' ], ['foo ' => 'Decimal:0,2 ' ]);
2892+ $ this ->assertTrue ($ v ->passes ());
2893+ $ v = new Validator ($ trans , ['foo ' => '-123 ' ], ['foo ' => 'Decimal:0,2 ' ]);
2894+ $ this ->assertTrue ($ v ->passes ());
2895+ $ v = new Validator ($ trans , ['foo ' => '+123. ' ], ['foo ' => 'Decimal:0,2 ' ]);
2896+ $ this ->assertTrue ($ v ->passes ());
2897+ $ v = new Validator ($ trans , ['foo ' => '-123. ' ], ['foo ' => 'Decimal:0,2 ' ]);
2898+ $ this ->assertTrue ($ v ->passes ());
2899+ $ v = new Validator ($ trans , ['foo ' => '123. ' ], ['foo ' => 'Decimal:0,2 ' ]);
2900+ $ this ->assertTrue ($ v ->passes ());
2901+ $ v = new Validator ($ trans , ['foo ' => '123. ' ], ['foo ' => 'Decimal:0,2 ' ]);
2902+ $ this ->assertTrue ($ v ->passes ());
2903+ $ v = new Validator ($ trans , ['foo ' => '123.34 ' ], ['foo ' => 'Decimal:0,2 ' ]);
2904+ $ this ->assertTrue ($ v ->passes ());
2905+ $ v = new Validator ($ trans , ['foo ' => '123.34 ' ], ['foo ' => 'Decimal:0,2 ' ]);
2906+ $ this ->assertTrue ($ v ->passes ());
28632907 }
28642908
28652909 public function testValidateInt ()
0 commit comments