PHPackages                             ekut/spatie-dto-validators - 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. ekut/spatie-dto-validators

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

ekut/spatie-dto-validators
==========================

Set of validators for the package spatie/data-transfer-object

v1.0.1(3y ago)2134MITPHPPHP ^8.0

Since May 16Pushed 3y ago1 watchersCompare

[ Source](https://github.com/ekut/spatie-dto-validators)[ Packagist](https://packagist.org/packages/ekut/spatie-dto-validators)[ RSS](/packages/ekut-spatie-dto-validators/feed)WikiDiscussions main Synced 1mo ago

READMEChangelog (2)Dependencies (2)Versions (4)Used By (0)

Set of validators for spatie/data-transfer-object package
=========================================================

[](#set-of-validators-for-spatiedata-transfer-object-package)

Installation
------------

[](#installation)

You can install the package via composer:

```
composer require ekut/spatie-dto-validators
```

- **Note**: This package only supports `php:^8.0`.

Usage
-----

[](#usage)

As you can see in Spatie DTO documentation [Validation](https://github.com/spatie/data-transfer-object#validation)chapter:

```
This package doesn't offer any specific validation functionality,
but it does give you a way to build your own validation attributes.

```

So, in this package we just collect set of tested validators for you can easily use it in your projects together with Spatie DTO.

```
use Ekut\SpatieDtoValidators\MinLength;
use Spatie\DataTransferObject\DataTransferObject;

class Foo extends DataTransferObject
{
    #[MinLength(10)]
    public ?string $property1;

    #[GreaterThan(10)]
    public ?int $property2;
}
```

If any of the validation will be violated, `Spatie\DataTransferObject\Exceptions\ValidationException` will be thrown with related user-friendly text message.

List of implemented validators
------------------------------

[](#list-of-implemented-validators)

### Basic

[](#basic)

#### Blank

[](#blank)

```
    #[Blank()]
```

Valid values:

- **false** (boolean)
- 0 (int)
- **\[\]** (empty array
- **''** (empty string)
- **""** (empty string)
- **null**
- **Note**: string **'0'** is invalid value.

#### NotBlank

[](#notblank)

```
    #[NotBlank(true|false)]
```

Boolean argument means: is null allowed?

Invalid values:

- **false** (boolean)
- 0 (int)
- **\[\]** (empty array
- **''** (empty string)
- **""** (empty string)
- **null** (if null is not allowed by argument)
- **Note**: string **'0'** is valid value.

#### NotNull

[](#notnull)

```
    #[NotNull()]
```

Only invalid value: **null**

#### IsNull

[](#isnull)

```
    #[IsNull()]
```

Only valid value: **null**

#### IsTrue

[](#istrue)

```
    #[IsTrue()]
```

Valid values:

- **true** (boolean)
- **1** (int)
- **'1'** (string)

#### IsFalse

[](#isfalse)

```
    #[IsFalse()]
```

Valid values:

- **false** (boolean)
- 0 (int)
- **'0'** (string)
- **null**

### Strings

[](#strings)

#### MinLength

[](#minlength)

```
    #[MinLength(3)]
```

Valid: 'car', 'lady', 333, etc.

Invalid: 'on', 'a', 12, 1, etc.

#### MaxLength

[](#maxlength)

```
    #[MaxLength(3)]
```

Valid: 'car', 'on', 'a', 333, 12, 1.

Invalid: 'lady', 'month', 9999, etc.

#### Email

[](#email)

```
    #[Email()]
```

Valid: '', '', '[some\_1@fake.com](mailto:some_1@fake.com)', ''.

Invalid: 'fake.com', 'fake@com'.

#### Url

[](#url)

```
    #[Url()]
```

Valid:

- ,
- ,
- ,
- ,
- [http://www.example.com/products?id=1&amp;page=2](http://www.example.com/products?id=1&page=2),
- ,
- ,
- //[www.site.com:8008](http://www.site.com:8008)

Invalid: 'some fake', '[www.example.com](http://www.example.com)', 'example.com'

### Comparison

[](#comparison)

#### EqualTo

[](#equalto)

```
    #[EqualTo(3)]
```

Valid values: 3, '3'.

#### NotEqualTo

[](#notequalto)

```
    #[EqualTo(3)]
```

Invalid values: 3, '3'.

#### IdenticalTo

[](#identicalto)

```
    #[IdenticalTo(3)]
```

Only valid value: 3.

#### NotIdenticalTo

[](#notidenticalto)

```
    #[NotIdenticalTo(3)]
```

Only invalid value: 3.

#### LessThan

[](#lessthan)

```
    #[LessThan(3)]
```

#### LessThanOrEqual

[](#lessthanorequal)

```
    #[LessThanOrEqual(3)]
```

#### GreaterThan

[](#greaterthan)

```
    #[GreaterThan(3)]
```

#### GreaterThanOrEqual

[](#greaterthanorequal)

```
    #[GreaterThanOrEqual(3)]
```

#### DivisibleBy

[](#divisibleby)

```
    #[DivisibleBy(3)]
    #[DivisibleBy(0.35)]
```

### Choice

[](#choice)

#### Choice

[](#choice-1)

```
    #[Choice([0, '1', false])]
```

License
-------

[](#license)

The MIT License (MIT). Please see [License File](LICENSE.md) for more information.

###  Health Score

27

—

LowBetter than 49% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity14

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity55

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

Every ~0 days

Total

2

Last Release

1456d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/d6ab628e9a1a159c020163de8aa7f00b821afe6b21ddb9004054efdcc52b05bd?d=identicon)[ekut](/maintainers/ekut)

---

Top Contributors

[![ekut](https://avatars.githubusercontent.com/u/6266596?v=4)](https://github.com/ekut "ekut (3 commits)")

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/ekut-spatie-dto-validators/health.svg)

```
[![Health](https://phpackages.com/badges/ekut-spatie-dto-validators/health.svg)](https://phpackages.com/packages/ekut-spatie-dto-validators)
```

###  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)[nette/forms

📝 Nette Forms: generating, validating and processing secure forms in PHP. Handy API, fully customizable, server &amp; client side validation and mature design.

54013.2M450](/packages/nette-forms)[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)

PHPackages © 2026

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