#591

Livewire provides built-in validation methods. You can use validate() method to handle form validation in your component.

// Livewire component class
class MyComponent extends Component
{
public $name;

public function submit()
{
$this->validate([
‘name’ => ‘required|min:3’,
]);

// Handle form submission
}

public function render()
{
return view(‘livewire.my-component’);
}
}

<!– Blade view for MyComponent –>
<div>
<form wire:submit.prevent=”submit”>
<input type=”text” wire:model=”name”>
@error(‘name’) <span class=”error”>{{ $message }}</span> @enderror
<button type=”submit”>Submit</button>
</form>
</div>