Use the ValidCarve rule in Form Requests to validate Carve markup.
This form works only in a local checkout. Clone the repository and run composer install && php artisan serve.
use MarkupCarve\LaravelCarve\Rules\ValidCarve;
class ArticleRequest extends FormRequest
{
public function rules(): array
{
return [
'title' => ['required', 'string', 'max:255'],
'body' => ['required', 'string', new ValidCarve()],
'comment' => ['nullable', 'string', new ValidCarve(strict: true)],
];
}
}
@carve($article->body)
{!! Carve::toHtml($comment, 'user_content') !!}