npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

@laravel-client-validation/vanilla

v0.1.1

Published

Vanilla JS adapter for Laravel Client Validation: attach Laravel-style rules to plain HTML forms with data attributes or a form validator factory.

Readme

@laravel-client-validation/vanilla

Vanilla JS adapter for Laravel Client Validation. Attach Laravel rule strings to plain HTML forms with data attributes — no framework required.

Requires @laravel-client-validation/core (installed automatically as a dependency).

Install

npm install @laravel-client-validation/vanilla

Usage

Mark a form with data-validate and declare rules per field with data-rules:

<form data-validate method="POST" action="/register">
    <input type="email" name="email" data-rules="required|email">
    <span class="validation-error" data-error="email"></span>

    <input type="password" name="password" data-rules="required|min:8" data-validate-on="blur">
    <input type="password" name="password_confirmation"
           data-rules="required|confirmed" data-attribute="password confirmation">

    <button type="submit">Sign up</button>
</form>
import { autoInit } from '@laravel-client-validation/vanilla';

autoInit();

On submit, every field is validated first; if anything fails the submit is blocked and the first error per field is shown. When all rules pass, your onSubmit callback runs or the form submits natively.

Auto-init

autoInit() binds every form[data-validate] on the page — it waits for DOMContentLoaded if the document is still loading. Repeated calls skip forms that already have a validator, so it is safe to call again after dynamic content loads. Alternatives:

import { initForms, createFormValidator } from '@laravel-client-validation/vanilla';

// Custom selector.
initForms('form[data-validate].signup');

// Manual, single form with options.
createFormValidator(form, {
    debounce: 200,
    onSubmit: (data, form) => fetch('/register', { method: 'POST', body: JSON.stringify(data) }),
});

Each VanillaFormValidator instance also exposes validateField(name), validateAll(), clearErrors(field?), getErrors(), and destroy(). Sibling inputs without data-rules are still collected as context so cross-field rules (confirmed, same, required_if) work. Individual fields get an el.validate() function, and each validation dispatches a bubbling validated CustomEvent with the result in event.detail.

Configuration

Defaults can be overridden globally before init via window.LaravelClientValidation.config, or per form through createFormValidator(form, options):

createFormValidator(form, {
    remoteUrl: '/client-validation/validate',
    debounce: 300,
    errorClass: 'validation-error text-red-500 text-sm mt-1',
    validClass: 'is-valid border-green-500',
    invalidClass: 'is-invalid border-red-500',
    showErrors: true,
});

Data attributes

| Attribute | Description | |-----------|-------------| | data-validate | Add to <form> to enable validation | | data-rules | Laravel-style rule string, e.g. required\|email | | data-validate-on | Trigger: blur (default), input/live, or submit | | data-message | Custom error message for the field's first rule | | data-attribute | Display name used in messages |

Documentation

https://mrpunyapal.github.io/laravel-client-validation/vanilla/