如何将 Laravel 自定义验证规则优先于默认规则

How to prioritize Laravel custom validation rule over defaults

我有一个自定义验证规则

'title' => ['required', 'min:3', 'unique:transport_locations,title,NULL,id,deleted_at,NULL', new TransportLocationIsInactive],

我想 运行 我的自定义规则,然后进行唯一性检查

'unique:transport_locations,title,NULL,id,deleted_at,NULL'

问题是它总是 运行 首先进行唯一检查,然后 returns "The location name has already been taken." :-(

只需更改顺序

'title' => [
    'required', // 1
    'min:3',    // 2
    new TransportLocationIsInactive, // 3
    'unique:transport_locations,title,NULL,id,deleted_at,NULL', // 4
],