add some validation to row edit, better handle setting null cols with empty

This commit is contained in:
2018-08-05 18:45:11 +02:00
parent 06fb01d146
commit 6cfd5aa7e9
13 changed files with 164 additions and 90 deletions
+3 -2
View File
@@ -4,6 +4,7 @@ namespace App\Tables;
use Illuminate\Contracts\Support\Arrayable;
use JsonSerializable;
use MightyPork\Exceptions\SimpleValidationException;
use MightyPork\Exceptions\NotApplicableException;
use MightyPork\Utils\Utils;
@@ -172,13 +173,13 @@ class Column implements JsonSerializable, Arrayable
if (is_int($value)) return $value;
if (is_float($value)) return round($value);
if (is_numeric($value)) return intval($value);
throw new NotApplicableException("Could not convert value \"$value\" to int!");
throw new SimpleValidationException($this->id, "Could not convert value \"$value\" to int!");
case 'float':
if (is_null($value)) return 0;
if (is_int($value) || is_float($value)) return (float)$value;
if (is_numeric($value)) return floatval($value);
throw new NotApplicableException("Could not convert value \"$value\" to float!");
throw new SimpleValidationException($this->id, "Could not convert value \"$value\" to float!");
case 'bool':
if (is_null($value)) return false;