31 public function validate($number, $config, $context)
38 if ($number ===
'0') {
45 if ($this->non_negative) {
50 $number = substr($number, 1);
53 if (ctype_digit($number)) {
54 $number = ltrim($number,
'0');
55 return $number ? $sign . $number :
'0';
59 if (strpos($number,
'.') ===
false) {
63 list($left, $right) = explode(
'.', $number, 2);
65 if ($left ===
'' && $right ===
'') {
68 if ($left !==
'' && !ctype_digit($left)) {
72 $left = ltrim($left,
'0');
73 $right = rtrim($right,
'0');
76 return $left ? $sign . $left :
'0';
77 } elseif (!ctype_digit($right)) {
80 return $sign . $left .
'.' . $right;