Custom Validation

I'm having a 2 fields: (1) Price (2) Checkbox

Task 1) If the price is less than a specific amount then the checkbox check is required.
Task 2) Display a validation error message only if the price is less than a specific amount. Form submit will be allowed

I've done below code and it's not working properly:

Forms\Components\TextInput::make('price')
->label('Price'),
Forms\Components\Toggle::make('checkbox')
->label('Checkbox')
->rules(['required_if:price,(X Amount)']),

I've tried with custom rule but it's not working properly.

How can I do this?
Was this page helpful?