- What is proengsoft/laravel-jsvalidation and how does it work?
- It is a Laravel package that compiles your PHP validation rules, messages, and FormRequest classes into a JavaScript rules object and hands it to a bundled jQuery Validation Plugin instance. Validation intent stays in PHP as a single source of truth while the browser validates forms automatically, with no JavaScript coding required. Rules that cannot run in the browser, such as unique, exists, active_url, and custom rules, are delegated to the server via AJAX. It is a UX layer only, so server-side validation must still run on every submit.
- How do I install laravel-jsvalidation with Composer?
- Run composer require proengsoft/laravel-jsvalidation, then publish the package config and the vendor/jsvalidation assets with artisan vendor:publish. After that you include the packaged script in your layout and add one Blade call per form. The README states the default configuration should work out of the box for most applications, so start there before customizing.
- Which Laravel and PHP versions does laravel-jsvalidation support?
- The README lists PHP 8.2 through 8.4 and Laravel 11.x through 13.x. However, the visible release notes stop at v4.4.4 from 2021, so verify the actual compatibility matrix against your target Laravel version before committing. Pin a specific version in composer.json and run your test suite against it.
- How do I validate a FormRequest on the client side with JsValidator?
- In your Blade view, call the JsValidator facade with the FormRequest class and a CSS selector for the form, for example JsValidator::formRequest('App\Http\Requests\StorePostRequest', '#my-form'). It renders a script block that wires jQuery Validation to that form using rules and messages derived from the request. Messages come from your request's messages() method and are translated through Laravel's localization layer.
- Does laravel-jsvalidation work with Livewire, Inertia, Vue or React?
- Not well. The package is a server-side rule compiler aimed at Blade-rendered forms with traditional POST submissions, and it depends on jQuery being present. In Inertia, React, Vue, or Livewire apps the front end usually does not consume Blade-rendered forms, so validation is better expressed in the client framework's own schema layer while reusing the same server rules. For API-first applications the package is effectively out of scope.
- How does AJAX validation work for unique, exists and active_url rules?
- Rules that need database or network access cannot be evaluated in the browser, so the package sends them to a server endpoint configured in the package config file and expects a JSON response. You point that setting at a route or controller action you control, and the bundled jQuery Validation remote method interprets the reply. Because the browser becomes a caller of your validation endpoints, plan auth, CSRF, throttling, and the response contract before enabling it in production.
- Is laravel-jsvalidation secure enough for production?
- Client-side validation is a UX improvement, never a security control, so keep all server-side validation and authorization in place. The AJAX-backed rules create an enumeration surface, for example letting someone probe whether an email address exists, so those endpoints need authentication, CSRF protection, rate limiting, and carefully worded responses. Treat any client rule as advisory and assume it can be bypassed.
- Which Laravel validation rules are not supported client-side?
- The README states that almost all Laravel rules are supported, but the present rule is not implemented and date_format does not handle timezone formats. Rule parity can also drift as Laravel adds new rules, so any new rule you introduce should be tested on both the client and server. Where parity breaks, decide in advance whether the fallback is degraded client UX or a server-side error on submit.
- How do I publish the config and handle assets, Vite and CSP with laravel-jsvalidation?
- Publish the package config and the vendor/jsvalidation assets, then include the packaged script in your layout or copy it into your asset pipeline. Under Laravel 11+ with Vite you may need to move the file into resources or public rather than relying on the old vendor path shown in older examples. The generated inline script can also be blocked by a strict Content Security Policy, so plan for nonces or hashes in your CSP headers.
- Is laravel-jsvalidation still maintained, and what are the alternatives?
- It is MIT licensed with community best-effort support and no commercial vendor behind it, and the ecosystem signal is modest at roughly 1.1k stars and no listed dependents. The README claims current Laravel support but the release notes look dated, so confirm maintenance activity before adopting it in a critical path. Alternatives include the browser's Constraint Validation API, lighter client-side validation libraries, or a front-end schema validation layer paired with the same server rules.