Hi, I'm looking to extend the discussion title character limit of 80 to 200 characters. Claude helped me come up with the code below, which I put in my extend.php file. I'm just curious if this is the correct way to handle this? Thanks!
<?php
/*
* This file is part of Flarum.
*
* For detailed copyright and license information, please view the
* LICENSE file that was distributed with this source code.
*/
use Flarum\Api\Resource\DiscussionResource;
use Flarum\Api\Schema;
use Flarum\Extend;
return [
/*
* Raise the discussion title limit from 80 to 200 characters.
*
* maxLength() appends a validation rule rather than replacing one,
* so core's max:80 has to be cleared first via rules([], true).
* That wipes the whole rules array, hence re-declaring string,
* requiredOnCreate and min:3 below — these mirror core's own
* definition on DiscussionResource.
*
* 200 is the ceiling without a migration: discussions.title is
* varchar(200).
*/
(new Extend\ApiResource(DiscussionResource::class))
->field('title', fn (Schema\Str $field) => $field
->rules([], true)
->rule('string')
->requiredOnCreate()
->minLength(3)
->maxLength(200)
),
];```