Maurits van der Schee 4 years ago
parent
commit
a7f1fb7aa3

+ 2
- 2
api.php View File

8433
     						break;
8433
     						break;
8434
     					case 'decimal':
8434
     					case 'decimal':
8435
     						if (strpos($value, '.') !== false) {
8435
     						if (strpos($value, '.') !== false) {
8436
-    							list($whole, $decimals) = explode('.', $value, 2);
8436
+    							list($whole, $decimals) = explode('.', ltrim($value, '-'), 2);
8437
     						} else {
8437
     						} else {
8438
-    							list($whole, $decimals) = array($value, '');
8438
+    							list($whole, $decimals) = array(ltrim($value, '-'), '');
8439
     						}
8439
     						}
8440
     						if (strlen($whole) > 0 && !ctype_digit($whole)) {
8440
     						if (strlen($whole) > 0 && !ctype_digit($whole)) {
8441
     							return 'invalid decimal';
8441
     							return 'invalid decimal';

+ 2
- 2
src/Tqdev/PhpCrudApi/Middleware/ValidationMiddleware.php View File

83
 						break;
83
 						break;
84
 					case 'decimal':
84
 					case 'decimal':
85
 						if (strpos($value, '.') !== false) {
85
 						if (strpos($value, '.') !== false) {
86
-							list($whole, $decimals) = explode('.', $value, 2);
86
+							list($whole, $decimals) = explode('.', ltrim($value, '-'), 2);
87
 						} else {
87
 						} else {
88
-							list($whole, $decimals) = array($value, '');
88
+							list($whole, $decimals) = array(ltrim($value, '-'), '');
89
 						}
89
 						}
90
 						if (strlen($whole) > 0 && !ctype_digit($whole)) {
90
 						if (strlen($whole) > 0 && !ctype_digit($whole)) {
91
 							return 'invalid decimal';
91
 							return 'invalid decimal';

+ 20
- 0
tests/functional/003_columns/015_update_types_table.log View File

112
 ===
112
 ===
113
 PUT /records/types/1
113
 PUT /records/types/1
114
 
114
 
115
+{"decimal":"-1.23"}
116
+===
117
+200
118
+Content-Type: application/json; charset=utf-8
119
+Content-Length: 1
120
+
121
+1
122
+===
123
+PUT /records/types/1
124
+
125
+{"decimal":"1.23"}
126
+===
127
+200
128
+Content-Type: application/json; charset=utf-8
129
+Content-Length: 1
130
+
131
+1
132
+===
133
+PUT /records/types/1
134
+
115
 {"decimal":"12.23.34"}
135
 {"decimal":"12.23.34"}
116
 ===
136
 ===
117
 422
137
 422

Loading…
Cancel
Save