1
0
mirror of https://github.com/flarum/core.git synced 2025-10-13 16:05:05 +02:00

More helpful avatar upload error messages

ref #165, #118
This commit is contained in:
Toby Zerner
2015-10-22 10:39:38 +10:30
parent a471a44ca6
commit ea98e4bda9
4 changed files with 48 additions and 25 deletions

View File

@@ -51,17 +51,6 @@ abstract class AbstractValidator
$this->translator = $translator;
}
/**
* Check whether a model is valid.
*
* @param array $attributes
* @return bool
*/
public function valid(array $attributes)
{
return $this->makeValidator($attributes)->passes();
}
/**
* Throw an exception if a model is not valid.
*
@@ -72,7 +61,7 @@ abstract class AbstractValidator
$validator = $this->makeValidator($attributes);
if ($validator->fails()) {
$this->throwValidationException($validator);
throw new ValidationException($validator);
}
}
@@ -92,15 +81,6 @@ abstract class AbstractValidator
return [];
}
/**
* @param Validator $validator
* @throws ValidationException
*/
protected function throwValidationException(Validator $validator)
{
throw new ValidationException($validator);
}
/**
* Make a new validator instance for this model.
*

View File

@@ -0,0 +1,22 @@
<?php
/*
* This file is part of Flarum.
*
* (c) Toby Zerner <toby.zerner@gmail.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Flarum\Core\Validator;
class AvatarValidator extends AbstractValidator
{
protected $rules = [
'avatar' => [
'required',
'image',
'max:1024'
]
];
}