Example of Custom validation rules in RatulSaqibKhan/emoji-calculator-laravel

File app/Rules/OperandRule.php (link to Github)
use Illuminate\Contracts\Validation\Rule;

class OperandRule implements Rule
{
    public function passes($attribute, $value)
    {
        $accepted_values = ['addition', 'subtraction', 'multiplication', 'division'];

        return in_array(strtolower($value), $accepted_values) ? true : false;
    }

    public function message()
    {
        return 'The given input is not valid!';
    }
}
File app/Http/Requests/CalculatorRequest.php (link to Github)
use App\Rules\OperandRule;
use Illuminate\Foundation\Http\FormRequest;

class CalculatorRequest extends FormRequest
{
    //
    public function rules()
    {
        return [
            'input1' => 'required|numeric',
            'operand' => ['required', 'string', new OperandRule],
            'input2' => 'required|numeric',
        ];
    }
}

Additional resources on custom validation rules: