PHPackages                             georgii-web/php-typed-values - 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. georgii-web/php-typed-values

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

georgii-web/php-typed-values
============================

Typed value objects library for common php data types.

v3.11.28(2mo ago)23.3k↓30.7%MITPHPPHP &gt;=8.4CI passing

Since Nov 19Pushed 2mo ago1 watchersCompare

[ Source](https://github.com/GeorgII-web/php-typed-values)[ Packagist](https://packagist.org/packages/georgii-web/php-typed-values)[ RSS](/packages/georgii-web-php-typed-values/feed)WikiDiscussions master Synced 1mo ago

READMEChangelog (10)Dependencies (12)Versions (222)Used By (0)

### PHP Typed Values

[](#php-typed-values)

Typed value objects for PHP. Build precise, immutable, and validated data for DTOs, Value Objects, and Entities.

[![Latest Version on Packagist](https://camo.githubusercontent.com/18d08fc3fb6649dc98829a62501f27f0945b8e7b582c5a4ce70db0bd8c5aba4f/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f67656f726769692d7765622f7068702d74797065642d76616c7565732e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/georgii-web/php-typed-values)[![Tests](https://github.com/georgii-web/php-typed-values/actions/workflows/php.yml/badge.svg)](https://github.com/georgii-web/php-typed-values/actions/workflows/php.yml)[![Total Downloads](https://camo.githubusercontent.com/f7115aa34e03e59ccb224a20ed69b36c8be7c81f1217ac452343a56e684cfef3/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f67656f726769692d7765622f7068702d74797065642d76616c7565732e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/georgii-web/php-typed-values)

---

### Install

[](#install)

- Use V3 for PHP 8.4:

```
composer require georgii-web/php-typed-values:^3
```

- Use V2 for PHP &gt;=8.2 &amp; &lt;8.4:

```
composer require georgii-web/php-typed-values:^2
```

- Use V1 for PHP 7.4:

```
composer require georgii-web/php-typed-values:^1
```

### Why

[](#why)

- Strong typing for scalars with runtime validation
- Immutable and self‑documenting values
- Safer constructors for your DTOs/VOs/Entities
- Great fit for static analysis
- Safe type conversion, no silent errors

### Quick start

[](#quick-start)

#### Use existing typed values

[](#use-existing-typed-values)

```
use PhpTypedValues\Integer\IntegerPositive;

$id = IntegerPositive::fromString('123');
```

Instead of spreading validation across an application

```
$id = (int) '123';
if ($id
