A status filter validated with an in: rule listing seven values, which had drifted from the eight the enum defined.
enum OrderStatus: string
{
case Pending = 'pending';
case Paid = 'paid';
// ...
}
// the rule, derived rather than written
'status' => ['nullable', Rule::enum(OrderStatus::class)],
// and the controller receives the case, not the string
public function index(OrderStatus|null $status = null) { /* ... */ }
The drift is the whole point: any list of valid values written twice will disagree eventually, and the second copy is usually in a validation rule where nobody looks. Deriving the rule from the enum means adding a case updates the API contract, which is right when the enum is the domain concept and wrong when the API deliberately exposes a subset — in which case a second enum is clearer than a filtered list.