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

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

noxkiwi/validator
=================

I am the validator library.

05[1 issues](https://github.com/noxkiwi/validator/issues)PHP

Since Jul 9Pushed 1y ago1 watchersCompare

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

READMEChangelogDependenciesVersions (3)Used By (0)

Validator - Providing Data Analysis Across Your Project
=======================================================

[](#validator---providing-data-analysis-across-your-project)

[![Security Rating](https://camo.githubusercontent.com/e2224166eeb202f61e92e6fec9e7cb88f101ff6b0bdb9893732e736a1673561a/68747470733a2f2f736f6e6172636c6f75642e696f2f6170692f70726f6a6563745f6261646765732f6d6561737572653f70726f6a6563743d6e6f786b6977695f76616c696461746f72266d65747269633d73656375726974795f726174696e67)](https://sonarcloud.io/summary/new_code?id=noxkiwi_validator)[![Code Smells](https://camo.githubusercontent.com/0ef123f0f7b72fcd4f322d440a3482280edae5af00833c52fa75d39133b1af8c/68747470733a2f2f736f6e6172636c6f75642e696f2f6170692f70726f6a6563745f6261646765732f6d6561737572653f70726f6a6563743d6e6f786b6977695f76616c696461746f72266d65747269633d636f64655f736d656c6c73)](https://sonarcloud.io/summary/new_code?id=noxkiwi_validator)[![Lines of Code](https://camo.githubusercontent.com/018bedb4d714fc54d7206f36ef9ec24e165c8e08783501a8cc9c5a823c10c6ca/68747470733a2f2f736f6e6172636c6f75642e696f2f6170692f70726f6a6563745f6261646765732f6d6561737572653f70726f6a6563743d6e6f786b6977695f76616c696461746f72266d65747269633d6e636c6f63)](https://sonarcloud.io/summary/new_code?id=noxkiwi_validator)[![Quality Gate Status](https://camo.githubusercontent.com/ba375fe9c08310432d1742b8e2f0610dff54e1b794fb24822d5fd182b369c515/68747470733a2f2f736f6e6172636c6f75642e696f2f6170692f70726f6a6563745f6261646765732f6d6561737572653f70726f6a6563743d6e6f786b6977695f76616c696461746f72266d65747269633d616c6572745f737461747573)](https://sonarcloud.io/summary/new_code?id=noxkiwi_validator)

It Began With a Mistake
-----------------------

[](#it-began-with-a-mistake)

In 2016, during the hectic initial phase of our startup, we made a critical mistake that impacted several months of invoice provisions for our sales managers. We mistakenly applied the netToGross tax calculation for sales tax multiple times, even on already gross values, leading to significant errors. This issue went unnoticed for several months, causing considerable trouble. As a result, we developed two separate libraries to ensure valid values across all our platforms.

The first commitment was to ensure valid parameters across the entire projects by creating the Value library. Then, as a logical conclusion, the next step was to implement a standard on how data has to be validated.

```
// The scenario is real, but this example is much simplified, of course.
function createUser(array $request): void {
    // validate field by field...
}
```

[Validator](https://validator.nox.kiwi) 💘 [Value](https://value.nox.kiwi)
=========================================================================

[](#validator--value)

### Validator

[](#validator)

- Checks input for integrity.
- Returns one or more detailed pieces of information on why an input is problematic.

### Value

[](#value)

- Can only be constructed with valid input.
- Once constructed, the input is immutable, ensuring integrity during runtime.

Just an Example
---------------

[](#just-an-example)

When validating data for integrity, you won't just need the fact that the input is problematic, you need a very detailed information on why the value actually is problematic. So we introduced the validator structure to almost every method that handles user input. We can't just validate numbers. There already is a collection of Validators. Example Validators:

```
IbanValidator
EmailValidator
DomainValidator
ConnectionValidator
And many more...

```

Here’s how you can use these Value objects: If you are going to use the Validator stack for user inputs, you can easily do things like these:

```
