State validation rule

This package provides a validation rule to validate incoming request data.

use Spatie\ModelStates\Validation\ValidStateRule;

request()->validate([
    'state' => new ValidStateRule(PaymentState::class),
]);

// Allowing null
request()->validate([
    'state' => ValidStateRule::make(PaymentState::class)->nullable(),
]);

Only valid state values of PaymentState implementations will be allowed.