Valeyard you could use a variation of this https://discuss.flarum.org/d/6507-change-user-validation-rules/9
However we have massively refactored the Flarum extension API around it recently. This is the new code that should be used:
<?php
use Flarum\Extend;
use Flarum\User\UserValidator;
use Illuminate\Support\Str;
return [
// Register extenders here
(new Extend\Validator(UserValidator::class))
->configure(function ($flarumValidator, $validator) {
$rules = $validator->getRules();
if (!array_key_exists('password', $rules)) {
return;
}
$rules['password'] = array_map(function (string $rule) {
if (Str::startsWith($rule, 'min:')) {
return 'min:16';
}
return $rule;
}, $rules['password']);
$validator->setRules($rules);
}),
];
There is a default password length in Flarum of course, it's 8. In my example code I change it to 16.
The array of $rules
can contain any Laravel validation rules. I use map
because I want to replace the existing min:
rule instead of just appending to the array.