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(4mo ago)02.6kMITPHPPHP &gt;=8.1.0CI passing

Since Feb 16Pushed 4mo agoCompare

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

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

Maintenance75

Regular maintenance activity

Popularity22

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

136d ago

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/43058421?v=4)[Nadyita](/maintainers/Nadyita)[@Nadyita](https://github.com/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

[marcosh/php-validation-dsl

A DSL for validating data in a functional fashion

483.9k](/packages/marcosh-php-validation-dsl)

PHPackages © 2026

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