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
@@ -0,0 +1,46 @@
<?php
namespace MightyPork\Exceptions;
use Illuminate\Contracts\Support\MessageProvider;
use Illuminate\Support\MessageBag;
class SimpleValidationException extends RuntimeException implements MessageProvider
{
/** @var MessageBag */
private $mb;
/**
* FBValidationException constructor.
*
* @param string|MessageProvider $key
* @param string $message
*/
public function __construct($key, $message = null)
{
if (is_null($message)) {
$this->mb = $key->getMessageBag();
} else {
$mb = new MessageBag();
$mb->add($key, $message);
$this->mb = $mb;
}
$str = '';
foreach ($this->mb->getMessages() as $key => $errors) {
$str .= $key . ': ' . implode(', ', $errors) . "\n";
}
parent::__construct($str);
}
/**
* Get the messages for the instance.
*
* @return MessageBag
*/
public function getMessageBag()
{
return $this->mb;
}
}