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(5y ago)19121MITPHP

Since Aug 5Pushed 5y 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 today

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 25% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity14

Limited adoption so far

Community9

Small or concentrated contributor base

Maturity42

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

1837d 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

[psalm/plugin-laravel

Psalm plugin for Laravel

3345.4M354](/packages/psalm-plugin-laravel)[spatie/laravel-honeypot

Preventing spam submitted through forms

1.6k7.1M83](/packages/spatie-laravel-honeypot)[mike-bronner/laravel-model-caching

Automatic caching for Eloquent models.

2.4k161.4k2](/packages/mike-bronner-laravel-model-caching)[illuminate/auth

The Illuminate Auth package.

9328.5M1.4k](/packages/illuminate-auth)[illuminate/routing

The Illuminate Routing package.

1239.4M3.5k](/packages/illuminate-routing)[sandermuller/laravel-fluent-validation

Fluent validation rule builders for Laravel

21428.9k6](/packages/sandermuller-laravel-fluent-validation)

PHPackages © 2026

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