PHPackages                             sfw2/validator - 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. sfw2/validator

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

sfw2/validator
==============

simple validation library

7.2.0(1y ago)011[1 PRs](https://github.com/papparazzo/sfw2-validator/pulls)AGPL-3.0-or-laterPHPPHP ^8.2CI passing

Since Nov 15Pushed 3mo ago1 watchersCompare

[ Source](https://github.com/papparazzo/sfw2-validator)[ Packagist](https://packagist.org/packages/sfw2/validator)[ RSS](/packages/sfw2-validator/feed)WikiDiscussions master Synced 1mo ago

READMEChangelogDependencies (3)Versions (17)Used By (0)

sfw2-validator
==============

[](#sfw2-validator)

Simple validator-class for checking and validating post-data.

How to use it
-------------

[](#how-to-use-it)

First create a new Rulset

```
    use SFW2\Validator\Ruleset;

    $rulset = new Ruleset();
```

Then add new rules for every $\_REQUEST-param. For example if you want to check set param "home" is set and not empty write:

```
    use SFW2\Validator\Validators\IsNotEmpty;

    $rulset->addNewRules('home', new IsNotEmpty());
```

if you want to check that "startTime" is a valid time write:

```
    use SFW2\Validator\Validators\IsNotEmpty;
    use SFW2\Validator\Validators\IsTime;

    $rulset->addNewRules('startTime', new IsNotEmpty(), new IsTime());
```

After setup all rules simply create a validator-object with the given rules and call "validate". The first param contains the REQUEST-data, the second param returns the validated and sanitized vales from REQUEST by reference. The boolean return-value of validate indicates a successfully validation of all params

```
    use SFW2\Validator\Validator;

    $validator = new Validator($rulset);
    $values = [];

    $error = $validator->validate($_POST, $values);
```

###  Health Score

42

—

FairBetter than 90% of packages

Maintenance63

Regular maintenance activity

Popularity5

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity78

Established project with proven stability

 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

Every ~136 days

Recently: every ~91 days

Total

15

Last Release

461d ago

Major Versions

2.0.1 → 3.0.02019-12-22

3.0.0 → 4.0.02020-06-13

4.1.0 → 5.0.02023-10-01

5.0.0 → 6.0.02023-11-07

6.3.0 → 7.0.02024-12-25

PHP version history (4 changes)1.0.0PHP ^7.3

2.0.0PHP ^7.4

5.0.0PHP ^8.1

6.2.0PHP ^8.2

### Community

Maintainers

![](https://www.gravatar.com/avatar/7ea6d5fa84340a33e81568df1b6572c05b0d590d0dd6ca0222a75d6d4b5a3a7d?d=identicon)[papparazzo](/maintainers/papparazzo)

---

Top Contributors

[![papparazzo](https://avatars.githubusercontent.com/u/4603702?v=4)](https://github.com/papparazzo "papparazzo (101 commits)")

---

Tags

micro-frameworksfw2

###  Code Quality

TestsPHPUnit

Static AnalysisPHPStan

Code StylePHP\_CodeSniffer

Type Coverage Yes

### Embed Badge

![Health badge](/badges/sfw2-validator/health.svg)

```
[![Health](https://phpackages.com/badges/sfw2-validator/health.svg)](https://phpackages.com/packages/sfw2-validator)
```

###  Alternatives

[webmozart/assert

Assertions to validate method input/output with nice error messages.

7.6k894.0M1.2k](/packages/webmozart-assert)[bensampo/laravel-enum

Simple, extensible and powerful enumeration implementation for Laravel.

2.0k15.9M104](/packages/bensampo-laravel-enum)[swaggest/json-schema

High definition PHP structures with JSON-schema based validation

48612.5M73](/packages/swaggest-json-schema)[stevebauman/purify

An HTML Purifier / Sanitizer for Laravel

5325.6M19](/packages/stevebauman-purify)[ashallendesign/laravel-config-validator

A package for validating your Laravel app's config.

217905.3k5](/packages/ashallendesign-laravel-config-validator)[crazybooot/base64-validation

Laravel validators for base64 encoded files

1341.9M8](/packages/crazybooot-base64-validation)

PHPackages © 2026

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