PHPackages                             kalshah/laravel-validation-html-attributes - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Validation &amp; Sanitization](/categories/validation)
4. /
5. kalshah/laravel-validation-html-attributes

ActiveLibrary[Validation &amp; Sanitization](/categories/validation)

kalshah/laravel-validation-html-attributes
==========================================

Use laravel backend validation rules as html validation attributes.

0.0.1(4y ago)19121MITPHP

Since Aug 5Pushed 4y ago2 watchersCompare

[ Source](https://github.com/KhawlahElshah/laravel-validation-html-attributes)[ Packagist](https://packagist.org/packages/kalshah/laravel-validation-html-attributes)[ RSS](/packages/kalshah-laravel-validation-html-attributes/feed)WikiDiscussions main Synced 3w ago

READMEChangelog (1)Dependencies (2)Versions (2)Used By (0)

Introduction
------------

[](#introduction)

This package comes up with an easy, smart way to pass laravel validation rules to html form and use it as client side validation.

---

Installation
------------

[](#installation)

This Package can be installed via Composer

```
composer require kalshah/laravel-validation-html-attributes
```

How it works
------------

[](#how-it-works)

The core work is done in a trait `WithHtmlAttributes` which can be used in two ways:

1- First by using the package request `LaravelValidationToHtmlAttributesRequest` which uses this trait, this suits you if you are validating request in controller methods

```
    public function create(LaravelValidationToHtmlAttributesRequest $request)
    {
        $request->setRules([
            'first_name' => 'required'
        ]);

        return view('form', ['attributes' => $request->htmlAttributes()]);
    }
```

2- Second by using the `WithHtmlAttributes` in your **FormRequest**

```
    use WithHtmlAttributes;
```

and in your controller you can pass the attributes like so:

```
    public function create()
    {
        return view('form', ['attributes' => (new WithHtmlAttributesFormRequest())->htmlAttributes()]);
    }
```

and in the blade files you can access these attributes and add them on html form inputs, like so:

```
first_name }}>
```

and lets assume the laravel validation rules of this field `first_name` were

```
return ['first_name' => 'required|min:2|string'];
```

the returned html validation inputs will be

```

```

as we can see the trait converted laravel validation rules to valid html validation attributes.

###  Health Score

23

—

LowBetter than 26% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity14

Limited adoption so far

Community9

Small or concentrated contributor base

Maturity41

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Unknown

Total

1

Last Release

1792d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/e92304a8bf2520f5be557e2a05b5039fda24c4d5cd0349c01096dc3fbacf24d8?d=identicon)[KhawlahElshah](/maintainers/KhawlahElshah)

---

Top Contributors

[![KhawlahElshah](https://avatars.githubusercontent.com/u/31843646?v=4)](https://github.com/KhawlahElshah "KhawlahElshah (9 commits)")

---

Tags

laravel-validationhtml validation attributes

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/kalshah-laravel-validation-html-attributes/health.svg)

```
[![Health](https://phpackages.com/badges/kalshah-laravel-validation-html-attributes/health.svg)](https://phpackages.com/packages/kalshah-laravel-validation-html-attributes)
```

###  Alternatives

[spatie/laravel-honeypot

Preventing spam submitted through forms

1.6k6.8M75](/packages/spatie-laravel-honeypot)[psalm/plugin-laravel

Psalm plugin for Laravel

3355.3M346](/packages/psalm-plugin-laravel)[wendelladriel/laravel-validated-dto

Data Transfer Objects with validation for Laravel applications

762649.9k18](/packages/wendelladriel-laravel-validated-dto)[pressbooks/pressbooks

Pressbooks is an open source book publishing tool built on a WordPress multisite platform. Pressbooks outputs books in multiple formats, including PDF, EPUB, web, and a variety of XML flavours, using a theming/templating system, driven by CSS.

45444.2k1](/packages/pressbooks-pressbooks)[bllim/laravalid

This package makes validation rules defined in laravel work client-side by converting to html/js plugins such as jquery validation. It also allows to use laravel validation messages so you can show same messages for both sides.

6015.3k](/packages/bllim-laravalid)[iamfarhad/validation

🇮🇷 Complete Laravel Persian validation package - Iranian national ID, mobile numbers, Shamsi dates, IBAN/Sheba, postal codes &amp; more. Modern Laravel 10-13 support with both ValidationRule objects &amp; string-based rules.

3017.3k](/packages/iamfarhad-validation)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
