PHPackages                             nadylib/type - 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. nadylib/type

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

nadylib/type
============

A library for ensuring and checking variable types

0.1.1(3mo ago)01.0kMITPHPPHP &gt;=8.1.0CI passing

Since Feb 16Pushed 3mo agoCompare

[ Source](https://github.com/Nadybot/Type)[ Packagist](https://packagist.org/packages/nadylib/type)[ RSS](/packages/nadylib-type/feed)WikiDiscussions main Synced 1mo ago

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

Nadylib\\Type
=============

[](#nadylibtype)

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

[](#introduction)

The type component of Nadylib is a ripped version of `Psl\Type` that was stripped down to be self-dependant and only has minimum requirements as well as working with PHP down to version 8.1. If you want a full framework, check out azjezz's awesome [PHP Standard Library](https://github.com/azjezz/psl).

`Nadylib\Type` provides a set of functions to ensure that a given value is of a specific type **at Runtime**. It aims to provide a solution for the [Parse, Don't Validate](https://lexi-lambda.github.io/blog/2019/11/05/parse-don-t-validate/) problem.

Usage
-----

[](#usage)

```
use Nadylib\Type;

$untrustedInput = $request->get('input');

// Turns a string-like value into a non-empty-string
$trustedInput = Type\nonEmptyString()->coerce($untrustedInput);

// Or assert that it's already a non-empty-string
$trustedInput = Type\nonEmptyString()->assert($untrustedInput);

// Or check if it's a non-empty-string
$isTrustworthy = Type\nonEmptyString()->matches($untrustedInput);
```

Every type provided by this component is an instance of `Type\TypeInterface`. This interface provides the following methods:

- `matches(mixed $value): $value is Tv` – Checks if the provided value is of the type.
- `assert(mixed $value): Tv` – Asserts that the provided value is of the type or throws an `AssertException` on failure.
- `coerce(mixed $value): Tv` – Coerces the provided value into the type or throws a `CoercionException` on failure.

Static Analysis
---------------

[](#static-analysis)

Your static analyzer should fully understand the types provided by this component if they support `@psalm-assert`. The only exception is `shape()` which would require a special component on the analyzers which is not available for `Nadylib\Type`. If you need this, use the [PHP Standard Library](https://github.com/azjezz/psl) instead.

###  Health Score

36

—

LowBetter than 82% of packages

Maintenance82

Actively maintained with recent releases

Popularity14

Limited adoption so far

Community6

Small or concentrated contributor base

Maturity34

Early-stage or recently created project

 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 ~1 days

Total

2

Last Release

90d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/43dd28040fa6867fe87ca2cf705fc4690c2cb856ca94a1b19f0efa1002d1f237?d=identicon)[Nadyita](/maintainers/Nadyita)

---

Top Contributors

[![Nadyita](https://avatars.githubusercontent.com/u/43058421?v=4)](https://github.com/Nadyita "Nadyita (2 commits)")

###  Code Quality

TestsPHPUnit

Static AnalysisPHPStan

Code StylePHP CS Fixer

Type Coverage Yes

### Embed Badge

![Health badge](/badges/nadylib-type/health.svg)

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

###  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)
