Documentation
Usage
Choose the right Laravel Client Validation integration and reuse the same rule grammar across Blade, Alpine, Livewire, Filament, vanilla JavaScript, React, Vue, and Inertia-driven apps.
On this page
Laravel Client Validation supports multiple integration styles, but the core idea stays the same: keep Laravel-style rule strings as the source of truth, pick when validation should run, and let remote rules fall through to Laravel when the browser needs backend context.
Shared building blocks
- The rule grammar matches Laravel validation strings.
- Trigger modes map cleanly across integrations:
blurby default,liveorinputfor immediate feedback, andsubmitorformwhen validation should block submission. - Remote rules such as
uniqueandexistsstill travel through the Laravel endpoint whenenable_ajax_validationis enabled.
Choose an integration page
- Use alpine for Blade directives,
x-validate, and thevalidation()helper. - Use livewire for
WithClientValidation,x-wire-validate, and client-side pre-validation in Livewire components. - Use filament for panel plugin setup,
ClientValidatedField, and custom Filament field traits. - Use vanilla when you want data attributes or imperative browser validation without a framework.
- Use react and vue for the shipped SPA adapters.
- Use inertia when your Laravel app uses Inertia with React or Vue. There is no dedicated Inertia adapter yet, so that page shows the supported composition pattern.
Shared remote-validation flow
<input name="email" @validateLive('email', 'required|email|unique:users,email')>
With the default configuration, the request is posted to client-validation/validate.
Programmatic validator
Every adapter ultimately wraps the same core validator.
import { LaravelValidator } from 'laravel-client-validation/core';
const validator = new LaravelValidator({
rules: {
email: 'required|email',
password: 'required|min:8',
},
messages: {
'email.required': 'Email is required.',
},
});
const fieldResult = await validator.validateField('email', 'name@example.com');
const formResult = await validator.validateAll({
email: 'name@example.com',
password: 'secret123',
});
Validation hooks
Hook into form lifecycle events when you need analytics, UI transitions, or custom logging.
const validator = new LaravelClientValidation.Validator({ rules });
validator
.beforeValidate(({ data }) => console.log('Validating', data))
.afterValidate(({ valid, errors }) => console.log('Done', valid, errors));
Related pages
- Use examples for larger snippets.
- Review custom rules when built-in rules are not sufficient.
- Keep troubleshooting close when remote validation and CSRF interact unexpectedly.