mirror of
https://github.com/flarum/core.git
synced 2025-08-06 08:27:42 +02:00
Refactor translation and validation
We now use Symfony's Translation component. Yay! We get more powerful pluralisation and better a fallback mechanism. Will want to implement the caching mechanism at some point too. The API is replicated in JavaScript, which could definitely use some testing. Validators have been refactored so that they are decoupled from models completely (i.e. they simply validate arrays of user input). Language packs should include Laravel's validation messages. ref #267
This commit is contained in:
@@ -13,6 +13,7 @@ namespace Flarum\Core\Command;
|
||||
use Flarum\Core\Access\AssertPermissionTrait;
|
||||
use Flarum\Core\Exception\PermissionDeniedException;
|
||||
use Flarum\Core\Group;
|
||||
use Flarum\Core\Validator\GroupValidator;
|
||||
use Flarum\Event\GroupWillBeSaved;
|
||||
use Flarum\Core\Support\DispatchEventsTrait;
|
||||
use Illuminate\Contracts\Events\Dispatcher;
|
||||
@@ -23,11 +24,18 @@ class CreateGroupHandler
|
||||
use AssertPermissionTrait;
|
||||
|
||||
/**
|
||||
* @param Dispatcher $events
|
||||
* @var GroupValidator
|
||||
*/
|
||||
public function __construct(Dispatcher $events)
|
||||
protected $validator;
|
||||
|
||||
/**
|
||||
* @param Dispatcher $events
|
||||
* @param GroupValidator $validator
|
||||
*/
|
||||
public function __construct(Dispatcher $events, GroupValidator $validator)
|
||||
{
|
||||
$this->events = $events;
|
||||
$this->validator = $validator;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -53,6 +61,8 @@ class CreateGroupHandler
|
||||
new GroupWillBeSaved($group, $actor, $data)
|
||||
);
|
||||
|
||||
$this->validator->assertValid($group->getAttributes());
|
||||
|
||||
$group->save();
|
||||
|
||||
$this->dispatchEventsFor($group, $actor);
|
||||
|
@@ -14,6 +14,7 @@ use Flarum\Core\Access\AssertPermissionTrait;
|
||||
use Flarum\Core\Exception\PermissionDeniedException;
|
||||
use Flarum\Core\Repository\DiscussionRepository;
|
||||
use Flarum\Core\Support\DispatchEventsTrait;
|
||||
use Flarum\Core\Validator\DiscussionValidator;
|
||||
use Flarum\Event\DiscussionWillBeSaved;
|
||||
use Illuminate\Contracts\Events\Dispatcher;
|
||||
|
||||
@@ -27,14 +28,21 @@ class EditDiscussionHandler
|
||||
*/
|
||||
protected $discussions;
|
||||
|
||||
/**
|
||||
* @var DiscussionValidator
|
||||
*/
|
||||
protected $validator;
|
||||
|
||||
/**
|
||||
* @param Dispatcher $events
|
||||
* @param DiscussionRepository $discussions
|
||||
* @param DiscussionValidator $validator
|
||||
*/
|
||||
public function __construct(Dispatcher $events, DiscussionRepository $discussions)
|
||||
public function __construct(Dispatcher $events, DiscussionRepository $discussions, DiscussionValidator $validator)
|
||||
{
|
||||
$this->events = $events;
|
||||
$this->discussions = $discussions;
|
||||
$this->validator = $validator;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -70,6 +78,8 @@ class EditDiscussionHandler
|
||||
new DiscussionWillBeSaved($discussion, $actor, $data)
|
||||
);
|
||||
|
||||
$this->validator->assertValid($discussion->getDirty());
|
||||
|
||||
$discussion->save();
|
||||
|
||||
$this->dispatchEventsFor($discussion, $actor);
|
||||
|
@@ -14,6 +14,7 @@ use Flarum\Core\Access\AssertPermissionTrait;
|
||||
use Flarum\Core\Exception\PermissionDeniedException;
|
||||
use Flarum\Core\Group;
|
||||
use Flarum\Core\Repository\GroupRepository;
|
||||
use Flarum\Core\Validator\GroupValidator;
|
||||
use Flarum\Event\GroupWillBeSaved;
|
||||
use Flarum\Core\Support\DispatchEventsTrait;
|
||||
use Illuminate\Contracts\Events\Dispatcher;
|
||||
@@ -28,14 +29,21 @@ class EditGroupHandler
|
||||
*/
|
||||
protected $groups;
|
||||
|
||||
/**
|
||||
* @var GroupValidator
|
||||
*/
|
||||
protected $validator;
|
||||
|
||||
/**
|
||||
* @param Dispatcher $events
|
||||
* @param GroupRepository $groups
|
||||
* @param GroupValidator $validator
|
||||
*/
|
||||
public function __construct(Dispatcher $events, GroupRepository $groups)
|
||||
public function __construct(Dispatcher $events, GroupRepository $groups, GroupValidator $validator)
|
||||
{
|
||||
$this->events = $events;
|
||||
$this->groups = $groups;
|
||||
$this->validator = $validator;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -70,6 +78,8 @@ class EditGroupHandler
|
||||
new GroupWillBeSaved($group, $actor, $data)
|
||||
);
|
||||
|
||||
$this->validator->assertValid($group->getDirty());
|
||||
|
||||
$group->save();
|
||||
|
||||
$this->dispatchEventsFor($group, $actor);
|
||||
|
@@ -12,6 +12,7 @@ namespace Flarum\Core\Command;
|
||||
|
||||
use Flarum\Core\Access\AssertPermissionTrait;
|
||||
use Flarum\Core\Repository\PostRepository;
|
||||
use Flarum\Core\Validator\PostValidator;
|
||||
use Flarum\Event\PostWillBeSaved;
|
||||
use Flarum\Core\Support\DispatchEventsTrait;
|
||||
use Flarum\Core\Post\CommentPost;
|
||||
@@ -27,14 +28,21 @@ class EditPostHandler
|
||||
*/
|
||||
protected $posts;
|
||||
|
||||
/**
|
||||
* @var PostValidator
|
||||
*/
|
||||
protected $validator;
|
||||
|
||||
/**
|
||||
* @param Dispatcher $events
|
||||
* @param PostRepository $posts
|
||||
* @param PostValidator $validator
|
||||
*/
|
||||
public function __construct(Dispatcher $events, PostRepository $posts)
|
||||
public function __construct(Dispatcher $events, PostRepository $posts, PostValidator $validator)
|
||||
{
|
||||
$this->events = $events;
|
||||
$this->posts = $posts;
|
||||
$this->validator = $validator;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -73,6 +81,8 @@ class EditPostHandler
|
||||
new PostWillBeSaved($post, $actor, $data)
|
||||
);
|
||||
|
||||
$this->validator->assertValid($post->getDirty());
|
||||
|
||||
$post->save();
|
||||
|
||||
$this->dispatchEventsFor($post, $actor);
|
||||
|
@@ -13,6 +13,7 @@ namespace Flarum\Core\Command;
|
||||
use Flarum\Core\Access\AssertPermissionTrait;
|
||||
use Flarum\Core\User;
|
||||
use Flarum\Core\Repository\UserRepository;
|
||||
use Flarum\Core\Validator\UserValidator;
|
||||
use Flarum\Event\UserWillBeSaved;
|
||||
use Flarum\Event\UserGroupsWereChanged;
|
||||
use Flarum\Core\Support\DispatchEventsTrait;
|
||||
@@ -28,14 +29,21 @@ class EditUserHandler
|
||||
*/
|
||||
protected $users;
|
||||
|
||||
/**
|
||||
* @var UserValidator
|
||||
*/
|
||||
protected $validator;
|
||||
|
||||
/**
|
||||
* @param Dispatcher $events
|
||||
* @param UserRepository $users
|
||||
* @param UserValidator $validator
|
||||
*/
|
||||
public function __construct(Dispatcher $events, UserRepository $users)
|
||||
public function __construct(Dispatcher $events, UserRepository $users, UserValidator $validator)
|
||||
{
|
||||
$this->events = $events;
|
||||
$this->users = $users;
|
||||
$this->validator = $validator;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -119,6 +127,8 @@ class EditUserHandler
|
||||
new UserWillBeSaved($user, $actor, $data)
|
||||
);
|
||||
|
||||
$this->validator->assertValid(array_merge($user->getDirty(), array_only($attributes, ['password', 'email'])));
|
||||
|
||||
$user->save();
|
||||
|
||||
$this->dispatchEventsFor($user, $actor);
|
||||
|
@@ -11,6 +11,7 @@
|
||||
namespace Flarum\Core\Command;
|
||||
|
||||
use Flarum\Core\Access\AssertPermissionTrait;
|
||||
use Flarum\Core\Validator\PostValidator;
|
||||
use Flarum\Event\PostWillBeSaved;
|
||||
use Flarum\Core\Repository\DiscussionRepository;
|
||||
use Flarum\Core\Post\CommentPost;
|
||||
@@ -33,19 +34,27 @@ class PostReplyHandler
|
||||
*/
|
||||
protected $notifications;
|
||||
|
||||
/**
|
||||
* @var PostValidator
|
||||
*/
|
||||
protected $validator;
|
||||
|
||||
/**
|
||||
* @param Dispatcher $events
|
||||
* @param DiscussionRepository $discussions
|
||||
* @param NotificationSyncer $notifications
|
||||
* @param PostValidator $validator
|
||||
*/
|
||||
public function __construct(
|
||||
Dispatcher $events,
|
||||
DiscussionRepository $discussions,
|
||||
NotificationSyncer $notifications
|
||||
NotificationSyncer $notifications,
|
||||
PostValidator $validator
|
||||
) {
|
||||
$this->events = $events;
|
||||
$this->discussions = $discussions;
|
||||
$this->notifications = $notifications;
|
||||
$this->validator = $validator;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -79,6 +88,8 @@ class PostReplyHandler
|
||||
new PostWillBeSaved($post, $actor, $command->data)
|
||||
);
|
||||
|
||||
$this->validator->assertValid($post->getAttributes());
|
||||
|
||||
$post->save();
|
||||
|
||||
$this->notifications->onePerUser(function () use ($post, $actor) {
|
||||
|
@@ -13,6 +13,7 @@ namespace Flarum\Core\Command;
|
||||
use Flarum\Core\Access\AssertPermissionTrait;
|
||||
use Flarum\Core\User;
|
||||
use Flarum\Core\AuthToken;
|
||||
use Flarum\Core\Validator\UserValidator;
|
||||
use Flarum\Event\UserWillBeSaved;
|
||||
use Flarum\Core\Support\DispatchEventsTrait;
|
||||
use Flarum\Settings\SettingsRepository;
|
||||
@@ -29,14 +30,21 @@ class RegisterUserHandler
|
||||
*/
|
||||
protected $settings;
|
||||
|
||||
/**
|
||||
* @var UserValidator
|
||||
*/
|
||||
protected $validator;
|
||||
|
||||
/**
|
||||
* @param Dispatcher $events
|
||||
* @param SettingsRepository $settings
|
||||
* @param UserValidator $validator
|
||||
*/
|
||||
public function __construct(Dispatcher $events, SettingsRepository $settings)
|
||||
public function __construct(Dispatcher $events, SettingsRepository $settings, UserValidator $validator)
|
||||
{
|
||||
$this->events = $events;
|
||||
$this->settings = $settings;
|
||||
$this->validator = $validator;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -88,6 +96,8 @@ class RegisterUserHandler
|
||||
new UserWillBeSaved($user, $actor, $data)
|
||||
);
|
||||
|
||||
$this->validator->assertValid(array_merge($user->getAttributes(), compact('password')));
|
||||
|
||||
$user->save();
|
||||
|
||||
if (isset($token)) {
|
||||
|
@@ -14,6 +14,7 @@ use Exception;
|
||||
use Flarum\Core\Access\AssertPermissionTrait;
|
||||
use Flarum\Core\Discussion;
|
||||
use Flarum\Core\Support\DispatchEventsTrait;
|
||||
use Flarum\Core\Validator\DiscussionValidator;
|
||||
use Flarum\Event\DiscussionWillBeSaved;
|
||||
use Illuminate\Contracts\Bus\Dispatcher as BusDispatcher;
|
||||
use Illuminate\Contracts\Events\Dispatcher as EventDispatcher;
|
||||
@@ -28,15 +29,22 @@ class StartDiscussionHandler
|
||||
*/
|
||||
protected $bus;
|
||||
|
||||
/**
|
||||
* @var DiscussionValidator
|
||||
*/
|
||||
protected $validator;
|
||||
|
||||
/**
|
||||
* @param EventDispatcher $events
|
||||
* @param BusDispatcher $bus
|
||||
* @param DiscussionValidator $validator
|
||||
* @internal param Forum $forum
|
||||
*/
|
||||
public function __construct(EventDispatcher $events, BusDispatcher $bus)
|
||||
public function __construct(EventDispatcher $events, BusDispatcher $bus, DiscussionValidator $validator)
|
||||
{
|
||||
$this->events = $events;
|
||||
$this->bus = $bus;
|
||||
$this->validator = $validator;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -64,6 +72,8 @@ class StartDiscussionHandler
|
||||
new DiscussionWillBeSaved($discussion, $actor, $data)
|
||||
);
|
||||
|
||||
$this->validator->assertValid($discussion->getAttributes());
|
||||
|
||||
$discussion->save();
|
||||
|
||||
// Now that the discussion has been created, we can add the first post.
|
||||
|
@@ -85,10 +85,6 @@ class CoreServiceProvider extends AbstractServiceProvider
|
||||
User::setHasher($this->app->make('hash'));
|
||||
User::setGate($this->app->make('flarum.gate'));
|
||||
|
||||
$this->validateModelWith(User::class, 'Flarum\Core\Validator\UserValidator');
|
||||
$this->validateModelWith(Group::class, 'Flarum\Core\Validator\GroupValidator');
|
||||
$this->validateModelWith(Post::class, 'Flarum\Core\Validator\PostValidator');
|
||||
|
||||
$events = $this->app->make('events');
|
||||
|
||||
$events->subscribe('Flarum\Core\Listener\DiscussionMetadataUpdater');
|
||||
@@ -129,15 +125,4 @@ class CoreServiceProvider extends AbstractServiceProvider
|
||||
$event->add('indexProfile', 'boolval', true);
|
||||
$event->add('locale');
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $model
|
||||
* @param string $validator
|
||||
*/
|
||||
protected function validateModelWith($model, $validator)
|
||||
{
|
||||
$model::saving(function ($model) use ($validator) {
|
||||
$this->app->make($validator)->assertValid($model);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
@@ -156,8 +156,6 @@ class User extends AbstractModel
|
||||
{
|
||||
$user = new static;
|
||||
|
||||
$user->assertValidPassword($password);
|
||||
|
||||
$user->username = $username;
|
||||
$user->email = $email;
|
||||
$user->password = $password;
|
||||
@@ -227,15 +225,6 @@ class User extends AbstractModel
|
||||
public function requestEmailChange($email)
|
||||
{
|
||||
if ($email !== $this->email) {
|
||||
$validator = $this->makeValidator();
|
||||
|
||||
$validator->setRules(array_only($validator->getRules(), 'email'));
|
||||
$validator->setData(compact('email'));
|
||||
|
||||
if ($validator->fails()) {
|
||||
$this->throwValidationException($validator);
|
||||
}
|
||||
|
||||
$this->raise(new UserEmailChangeWasRequested($this, $email));
|
||||
}
|
||||
|
||||
@@ -250,8 +239,6 @@ class User extends AbstractModel
|
||||
*/
|
||||
public function changePassword($password)
|
||||
{
|
||||
$this->assertValidPassword($password);
|
||||
|
||||
$this->password = $password;
|
||||
|
||||
$this->raise(new UserPasswordWasChanged($this));
|
||||
@@ -259,20 +246,6 @@ class User extends AbstractModel
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Validate password input.
|
||||
*
|
||||
* @param string $password
|
||||
* @return void
|
||||
* @throws \Flarum\Core\Exception\ValidationException
|
||||
*/
|
||||
protected function assertValidPassword($password)
|
||||
{
|
||||
if (strlen($password) < 8) {
|
||||
throw new ValidationException(['password' => 'Password must be at least 8 characters']);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the password attribute, storing it as a hash.
|
||||
*
|
||||
|
@@ -10,14 +10,14 @@
|
||||
|
||||
namespace Flarum\Core\Validator;
|
||||
|
||||
use Flarum\Database\AbstractModel;
|
||||
use Flarum\Event\ConfigureModelValidator;
|
||||
use Flarum\Event\ConfigureValidator;
|
||||
use Illuminate\Contracts\Events\Dispatcher;
|
||||
use Illuminate\Contracts\Validation\ValidationException;
|
||||
use Illuminate\Validation\Factory;
|
||||
use Illuminate\Validation\Validator;
|
||||
use Symfony\Component\Translation\TranslatorInterface;
|
||||
|
||||
class AbstractValidator
|
||||
abstract class AbstractValidator
|
||||
{
|
||||
/**
|
||||
* @var array
|
||||
@@ -35,39 +35,63 @@ class AbstractValidator
|
||||
protected $events;
|
||||
|
||||
/**
|
||||
* @param Factory $validator
|
||||
* @var TranslatorInterface
|
||||
*/
|
||||
public function __construct(Factory $validator, Dispatcher $events)
|
||||
protected $translator;
|
||||
|
||||
/**
|
||||
* @param Factory $validator
|
||||
* @param Dispatcher $events
|
||||
* @param TranslatorInterface $translator
|
||||
*/
|
||||
public function __construct(Factory $validator, Dispatcher $events, TranslatorInterface $translator)
|
||||
{
|
||||
$this->validator = $validator;
|
||||
$this->events = $events;
|
||||
$this->translator = $translator;
|
||||
}
|
||||
|
||||
/**
|
||||
* Check whether a model is valid.
|
||||
*
|
||||
* @param AbstractModel $model
|
||||
* @param array $attributes
|
||||
* @return bool
|
||||
*/
|
||||
public function valid(AbstractModel $model)
|
||||
public function valid(array $attributes)
|
||||
{
|
||||
return $this->makeValidator($model)->passes();
|
||||
return $this->makeValidator($attributes)->passes();
|
||||
}
|
||||
|
||||
/**
|
||||
* Throw an exception if a model is not valid.
|
||||
*
|
||||
* @throws ValidationException
|
||||
* @param array $attributes
|
||||
*/
|
||||
public function assertValid(AbstractModel $model)
|
||||
public function assertValid(array $attributes)
|
||||
{
|
||||
$validator = $this->makeValidator($model);
|
||||
$validator = $this->makeValidator($attributes);
|
||||
|
||||
if ($validator->fails()) {
|
||||
$this->throwValidationException($validator);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
protected function getRules()
|
||||
{
|
||||
return $this->rules;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
protected function getMessages()
|
||||
{
|
||||
return [];
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Validator $validator
|
||||
* @throws ValidationException
|
||||
@@ -80,72 +104,19 @@ class AbstractValidator
|
||||
/**
|
||||
* Make a new validator instance for this model.
|
||||
*
|
||||
* @param AbstractModel $model
|
||||
* @param array $attributes
|
||||
* @return \Illuminate\Validation\Validator
|
||||
*/
|
||||
protected function makeValidator(AbstractModel $model)
|
||||
protected function makeValidator(array $attributes)
|
||||
{
|
||||
$rules = $this->expandUniqueRules($this->rules, $model);
|
||||
$rules = array_only($this->getRules(), array_keys($attributes));
|
||||
|
||||
$validator = $this->validator->make($model->getAttributes(), $rules);
|
||||
$validator = $this->validator->make($attributes, $rules, $this->getMessages());
|
||||
|
||||
$this->events->fire(
|
||||
new ConfigureModelValidator($model, $validator)
|
||||
new ConfigureValidator($this, $validator)
|
||||
);
|
||||
|
||||
return $validator;
|
||||
}
|
||||
|
||||
/**
|
||||
* Expand 'unique' rules in a set of validation rules into a fuller form
|
||||
* that Laravel's validator can understand.
|
||||
*
|
||||
* @param array $rules
|
||||
* @param AbstractModel $model
|
||||
* @return array
|
||||
*/
|
||||
protected function expandUniqueRules($rules, AbstractModel $model)
|
||||
{
|
||||
foreach ($rules as $attribute => &$ruleset) {
|
||||
if (is_string($ruleset)) {
|
||||
$ruleset = explode('|', $ruleset);
|
||||
}
|
||||
|
||||
foreach ($ruleset as &$rule) {
|
||||
if (strpos($rule, 'unique') === 0) {
|
||||
$rule = $this->expandUniqueRule($attribute, $rule, $model);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return $rules;
|
||||
}
|
||||
|
||||
/**
|
||||
* Expand a 'unique' rule into a fuller form that Laravel's validator can
|
||||
* understand, based on this model's properties.
|
||||
*
|
||||
* @param string $attribute
|
||||
* @param string $rule
|
||||
* @param AbstractModel $model
|
||||
* @return string
|
||||
*/
|
||||
protected function expandUniqueRule($attribute, $rule, AbstractModel $model)
|
||||
{
|
||||
$parts = explode(':', $rule);
|
||||
$key = $model->getKey() ?: 'NULL';
|
||||
$rule = 'unique:'.$model->getTable().','.$attribute.','.$key.','.$model->getKeyName();
|
||||
|
||||
if (! empty($parts[1])) {
|
||||
$wheres = explode(',', $parts[1]);
|
||||
|
||||
foreach ($wheres as &$where) {
|
||||
$where .= ','.$this->$where;
|
||||
}
|
||||
|
||||
$rule .= ','.implode(',', $wheres);
|
||||
}
|
||||
|
||||
return $rule;
|
||||
}
|
||||
}
|
||||
|
@@ -13,15 +13,10 @@ namespace Flarum\Core\Validator;
|
||||
class DiscussionValidator extends AbstractValidator
|
||||
{
|
||||
protected $rules = [
|
||||
'title' => ['required', 'max:80'],
|
||||
'start_time' => ['required', 'date'],
|
||||
'comments_count' => ['integer'],
|
||||
'participants_count' => ['integer'],
|
||||
'start_user_id' => ['integer'],
|
||||
'start_post_id' => ['integer'],
|
||||
'last_time' => ['date'],
|
||||
'last_user_id' => ['integer'],
|
||||
'last_post_id' => ['integer'],
|
||||
'last_post_number' => ['integer'],
|
||||
'title' => [
|
||||
'required',
|
||||
'min:3',
|
||||
'max:80'
|
||||
]
|
||||
];
|
||||
}
|
||||
|
@@ -13,14 +13,9 @@ namespace Flarum\Core\Validator;
|
||||
class PostValidator extends AbstractValidator
|
||||
{
|
||||
protected $rules = [
|
||||
'discussion_id' => ['required', 'integer'],
|
||||
'time' => ['required', 'date'],
|
||||
'content' => ['required', 'max:65535'],
|
||||
'number' => ['integer'],
|
||||
'user_id' => ['integer'],
|
||||
'edit_time' => ['date'],
|
||||
'edit_user_id' => ['integer'],
|
||||
'hide_time' => ['date'],
|
||||
'hide_user_id' => ['integer']
|
||||
'content' => [
|
||||
'required',
|
||||
'max:65535'
|
||||
]
|
||||
];
|
||||
}
|
||||
|
@@ -13,12 +13,21 @@ namespace Flarum\Core\Validator;
|
||||
class UserValidator extends AbstractValidator
|
||||
{
|
||||
protected $rules = [
|
||||
'username' => ['required', 'alpha_dash', 'unique', 'min:3', 'max:30'],
|
||||
'email' => ['required', 'email', 'unique'],
|
||||
'password' => ['required'],
|
||||
'join_time' => ['date'],
|
||||
'last_seen_time' => ['date'],
|
||||
'discussions_count' => ['integer'],
|
||||
'posts_count' => ['integer']
|
||||
'username' => [
|
||||
'required',
|
||||
'alpha_dash',
|
||||
'unique:users',
|
||||
'min:3',
|
||||
'max:8'
|
||||
],
|
||||
'email' => [
|
||||
'required',
|
||||
'email',
|
||||
'unique:users'
|
||||
],
|
||||
'password' => [
|
||||
'required',
|
||||
'min:8'
|
||||
]
|
||||
];
|
||||
}
|
||||
|
Reference in New Issue
Block a user